当前位置: 首页>>代码示例>>Python>>正文


Python SimpleSQLite.insert_many方法代码示例

本文整理汇总了Python中simplesqlite.SimpleSQLite.insert_many方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleSQLite.insert_many方法的具体用法?Python SimpleSQLite.insert_many怎么用?Python SimpleSQLite.insert_many使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在simplesqlite.SimpleSQLite的用法示例。


在下文中一共展示了SimpleSQLite.insert_many方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SimpleSQLite

# 需要导入模块: from simplesqlite import SimpleSQLite [as 别名]
# 或者: from simplesqlite.SimpleSQLite import insert_many [as 别名]
#!/usr/bin/env python
# encoding: utf-8

from __future__ import print_function

from simplesqlite import SimpleSQLite


table_name = "sample_table"
con = SimpleSQLite("sample.sqlite", "w")
con.create_table_from_data_matrix(
    table_name, ["attr_a", "attr_b", "attr_c", "attr_d", "attr_e"], [[1, 1.1, "aaa", 1, 1]]
)

con.insert(
    table_name,
    record={"attr_a": 4, "attr_b": 4.4, "attr_c": "ddd", "attr_d": 4.44, "attr_e": "hoge"},
)
con.insert_many(
    table_name,
    records=[
        {"attr_a": 5, "attr_b": 5.5, "attr_c": "eee", "attr_d": 5.55, "attr_e": "foo"},
        {"attr_a": 6, "attr_c": "fff"},
    ],
)

result = con.select(select="*", table_name=table_name)
for record in result.fetchall():
    print(record)
开发者ID:thombashi,项目名称:SimpleSQLite,代码行数:31,代码来源:sample_insert_dict.py

示例2: print

# 需要导入模块: from simplesqlite import SimpleSQLite [as 别名]
# 或者: from simplesqlite.SimpleSQLite import insert_many [as 别名]
    data_matrix=[[1, 1.1, "aaa", 1,   1]])

con.insert(
    table_name,
    insert_record={
        "attr_a": 4,
        "attr_b": 4.4,
        "attr_c": "ddd",
        "attr_d": 4.44,
        "attr_e": "hoge",
    })
con.insert_many(
    table_name,
    insert_record_list=[
        {
            "attr_a": 5,
            "attr_b": 5.5,
            "attr_c": "eee",
            "attr_d": 5.55,
            "attr_e": "foo",
        },
        {
            "attr_a": 6,
            "attr_c": "fff",
        },
    ])

result = con.select(select="*", table_name=table_name)
for record in result.fetchall():
    print(record)
开发者ID:yedan2010,项目名称:SimpleSQLite,代码行数:32,代码来源:sample_insert_dict.py

示例3: SimpleSQLite

# 需要导入模块: from simplesqlite import SimpleSQLite [as 别名]
# 或者: from simplesqlite.SimpleSQLite import insert_many [as 别名]
#!/usr/bin/env python
# encoding: utf-8

from __future__ import print_function

from collections import namedtuple
from simplesqlite import SimpleSQLite


table_name = "sample_table"
con = SimpleSQLite("sample.sqlite", "w")
con.create_table_from_data_matrix(
    table_name,
    attr_name_list=["attr_a", "attr_b", "attr_c", "attr_d", "attr_e"],
    data_matrix=[[1, 1.1, "aaa", 1,   1]])

SampleTuple = namedtuple(
    "SampleTuple", "attr_a attr_b attr_c attr_d attr_e")

con.insert(table_name, insert_record=[7, 7.7, "fff", 7.77, "bar"])
con.insert_many(
    table_name,
    insert_record_list=[
        (8, 8.8, "ggg", 8.88, "foobar"),
        SampleTuple(9, 9.9, "ggg", 9.99, "hogehoge"),
    ])

result = con.select(select="*", table_name=table_name)
for record in result.fetchall():
    print(record)
开发者ID:yedan2010,项目名称:SimpleSQLite,代码行数:32,代码来源:sample_insert_mix_data.py


注:本文中的simplesqlite.SimpleSQLite.insert_many方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。