📜  python sql passer des parametres dans une requet pymysql 代码示例

📅  最后修改于: 2022-03-11 15:05:23.845000             🧑  作者: Mango

代码示例1
# Connect to db
# Open a cursor
stmt = "SELECT * FROM users WHERE username = %(user)s"
cursor.execute(stmt, {"user": "bob"})
user = cursor.fetchone()
print user

{"username": "bob", "alias": "bobby", "avatar": "default", "fullname": "bob"}