本文整理匯總了Python中Cerebrum.Utils.argument_to_sql方法的典型用法代碼示例。如果您正苦於以下問題:Python Utils.argument_to_sql方法的具體用法?Python Utils.argument_to_sql怎麽用?Python Utils.argument_to_sql使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Cerebrum.Utils
的用法示例。
在下文中一共展示了Utils.argument_to_sql方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_argument_to_sql_droptables
# 需要導入模塊: from Cerebrum import Utils [as 別名]
# 或者: from Cerebrum.Utils import argument_to_sql [as 別名]
def test_argument_to_sql_droptables():
""" Utils.argument_to_sql with Bobby Tables. """
binds = {}
name = "Robert'; DROP TABLE Students;--"
sql = Utils.argument_to_sql(name, 'name', binds)
assert sql == '(name = :name)'
assert binds == {'name': name} # This function should not sanitize. That's
示例2: test_argument_to_sql_sequence
# 需要導入模塊: from Cerebrum import Utils [as 別名]
# 或者: from Cerebrum.Utils import argument_to_sql [as 別名]
def test_argument_to_sql_sequence():
""" Utils.argument_to_sql with sequence. """
sequence = [1, 2, 3]
for seq_type in (tuple, set, list):
binds = {}
sql = Utils.argument_to_sql(seq_type(sequence), 'foo', binds)
assert sql == '(foo IN (:foo0, :foo1, :foo2))'
assert binds == {'foo0': 1, 'foo1': 2, 'foo2': 3}
示例3: clear_state
# 需要導入模塊: from Cerebrum import Utils [as 別名]
# 或者: from Cerebrum.Utils import argument_to_sql [as 別名]
def clear_state(self, state_types=None):
""" Remove session state data.
Session state data mainly constists of cached passwords for the
misc_list_passwords command.
"""
sql = """DELETE FROM [:table schema=cerebrum name=bofhd_session_state]
WHERE session_id=:session_id"""
binds = {"session_id": self.get_session_id()}
if state_types:
sql += " AND " + Utils.argument_to_sql(state_types, "state_type", binds, str)
self._db.execute(sql, binds)
self._remove_old_sessions()
示例4: test_argument_to_sql_transform
# 需要導入模塊: from Cerebrum import Utils [as 別名]
# 或者: from Cerebrum.Utils import argument_to_sql [as 別名]
def test_argument_to_sql_transform():
""" Utils.argument_to_sql with transform function. """
binds = {}
sql = Utils.argument_to_sql(None, 'foo', binds, type)
assert sql == '(foo = :foo)'
assert binds == {'foo': type(None)}