New utility function execute_query, wrapping cursor.execute.
This is a hack to avoid a problem with using %(foo)d in a query with a NULL value.
This commit is contained in:
parent
b34f8da82b
commit
87e0cdda9d
|
@ -1,6 +1,12 @@
|
||||||
import os
|
import os
|
||||||
import tempfile
|
import tempfile
|
||||||
|
|
||||||
|
def execute_query(cursor, query, bindings):
|
||||||
|
for (key, val) in bindings.items():
|
||||||
|
if val == None:
|
||||||
|
query = query.replace('%(' + key + ')d', 'NULL')
|
||||||
|
cursor.execute(query, bindings)
|
||||||
|
|
||||||
def make_result_dict(cursor, row):
|
def make_result_dict(cursor, row):
|
||||||
d = {}
|
d = {}
|
||||||
for i in xrange(len(row)):
|
for i in xrange(len(row)):
|
||||||
|
|
Reference in New Issue