本文整理匯總了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