Any way using pyodbc to return literal SQL
Is there any way using pyodbc to return the literal sql that was passed to
the database? I'm passing parameters to statements within a for loop
iterating over a list of dictionaries. For example:
mylist = [{'name': 'john', 'key': 1}, {'name': 'jane', 'key': 2}]
sql = "update people set name = ? where key = ?"
for i in mylist:
cursor.execute(sql, i['name'], i['key'])
I'd like to be able to print or store the literal sql that the script is
passing to the database. If this is not possible using pyodbc, can someone
recommend a different Python module that has this feature? Thanks in
advance.
No comments:
Post a Comment