本文整理汇总了Python中DB.mogrify方法的典型用法代码示例。如果您正苦于以下问题:Python DB.mogrify方法的具体用法?Python DB.mogrify怎么用?Python DB.mogrify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DB
的用法示例。
在下文中一共展示了DB.mogrify方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: registerPlayer
# 需要导入模块: import DB [as 别名]
# 或者: from DB import mogrify [as 别名]
def registerPlayer(name):
"""Adds a player to the tournament database.
Args:
name: the player's full name (need not be unique).
"""
cursor = DB().cursor()
# Get already escaped SQL statement
query = cursor.mogrify("INSERT INTO players (name) VALUES (%s)", (name,))
DB().execute(query, True)
示例2: reportMatch
# 需要导入模块: import DB [as 别名]
# 或者: from DB import mogrify [as 别名]
def reportMatch(winner, loser):
"""Records the outcome of a single match between two players.
Args:
winner: the id number of the player who won
loser: the id number of the player who lost
"""
cursor = DB().cursor()
query = cursor.mogrify(
"INSERT INTO matches (winner, loser) VALUES (%s, %s)", (winner, loser))
DB().execute(query, True)