本文整理汇总了Python中simplesqlite.sqlquery.SqlQuery.make_where方法的典型用法代码示例。如果您正苦于以下问题:Python SqlQuery.make_where方法的具体用法?Python SqlQuery.make_where怎么用?Python SqlQuery.make_where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simplesqlite.sqlquery.SqlQuery
的用法示例。
在下文中一共展示了SqlQuery.make_where方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_normal
# 需要导入模块: from simplesqlite.sqlquery import SqlQuery [as 别名]
# 或者: from simplesqlite.sqlquery.SqlQuery import make_where [as 别名]
def test_normal(self, con):
table_name = TEST_TABLE_NAME
where = SqlQuery.make_where("attr_b", 2)
con.update(
table_name=table_name, set_query="attr_a = 100", where=where)
assert con.get_value(
select="attr_a", table_name=table_name, where=where) == 100
示例2: SimpleSQLite
# 需要导入模块: from simplesqlite.sqlquery import SqlQuery [as 别名]
# 或者: from simplesqlite.sqlquery.SqlQuery import make_where [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)
示例3: test_exception
# 需要导入模块: from simplesqlite.sqlquery import SqlQuery [as 别名]
# 或者: from simplesqlite.sqlquery.SqlQuery import make_where [as 别名]
def test_exception(self, key, value, operation, expected):
with pytest.raises(expected):
SqlQuery.make_where(key, value, operation)
示例4: test_normal
# 需要导入模块: from simplesqlite.sqlquery import SqlQuery [as 别名]
# 或者: from simplesqlite.sqlquery.SqlQuery import make_where [as 别名]
def test_normal(self, key, value, operation, expected):
assert SqlQuery.make_where(key, value, operation) == expected