本文整理汇总了Python中simplesqlite.SimpleSQLite.update方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleSQLite.update方法的具体用法?Python SimpleSQLite.update怎么用?Python SimpleSQLite.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simplesqlite.SimpleSQLite
的用法示例。
在下文中一共展示了SimpleSQLite.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SimpleSQLite
# 需要导入模块: from simplesqlite import SimpleSQLite [as 别名]
# 或者: from simplesqlite.SimpleSQLite import update [as 别名]
#!/usr/bin/env python
# encoding: utf-8
from __future__ import print_function
from simplesqlite import SimpleSQLite
from simplesqlite.query import Where
table_name = "sample_table"
con = SimpleSQLite("sample.sqlite", "w")
data_matrix = [[1, "aaa"], [2, "bbb"]]
con.create_table_from_data_matrix(table_name, ["key", "value"], data_matrix)
print("---- before update ----")
for record in con.select(select="*", table_name=table_name).fetchall():
print(record)
print()
con.update(table_name, set_query="value = 'ccc'", where=Where(key="key", value=1))
print("---- after update ----")
for record in con.select(select="*", table_name=table_name).fetchall():
print(record)
示例2: SimpleSQLite
# 需要导入模块: from simplesqlite import SimpleSQLite [as 别名]
# 或者: from simplesqlite.SimpleSQLite import update [as 别名]
from simplesqlite import SimpleSQLite
from simplesqlite.sqlquery import SqlQuery
table_name = "sample_table"
con = SimpleSQLite("sample.sqlite", "w")
data_matrix = [
[1, "aaa"],
[2, "bbb"],
]
con.create_table_from_data_matrix(
table_name,
attr_name_list=["key", "value"],
data_matrix=data_matrix)
print("---- before update ----")
for record in con.select(select="*", table_name=table_name).fetchall():
print(record)
print()
con.update(
table_name,
set_query="value = 'ccc'",
where=SqlQuery.make_where(key="key", value=1))
print("---- after update ----")
for record in con.select(select="*", table_name=table_name).fetchall():
print(record)