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:
Øystein Ingmar Skartsæterhagen 2011-10-08 19:20:21 +00:00
parent b34f8da82b
commit 87e0cdda9d

View File

@ -1,6 +1,12 @@
import os
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):
d = {}
for i in xrange(len(row)):