本文整理匯總了Python中simplesqlite.sqlquery.SqlQuery類的典型用法代碼示例。如果您正苦於以下問題:Python SqlQuery類的具體用法?Python SqlQuery怎麽用?Python SqlQuery使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了SqlQuery類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_normal
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: test_normal
def test_normal(self, table, set_query, where, expected):
assert SqlQuery.make_update(table, set_query, where) == expected
示例3: test_normal
def test_normal(self, value, operation, expected):
assert SqlQuery.to_attr_str(value, operation) == expected
示例4: test_exception
def test_exception(self, value, expected):
with pytest.raises(expected):
assert SqlQuery.to_table_str(value)
示例5: test_abnormal
def test_abnormal(self, value, expected):
with pytest.raises(expected):
SqlQuery.sanitize(value)
示例6: test_exception
def test_exception(self, key, value, expected):
with pytest.raises(expected):
SqlQuery.make_where_not_in(key, value)
示例7: SimpleSQLite
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)