本文整理汇总了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)