Skip to content

Instantly share code, notes, and snippets.

@hdknr
Created September 9, 2009 06:17
Show Gist options
  • Save hdknr/183514 to your computer and use it in GitHub Desktop.
Save hdknr/183514 to your computer and use it in GitHub Desktop.
def _execSQL(self, sql_name, *args):
sql = self._getSQL(sql_name)
# Kludge because we have reports of postgresql not quoting
# arguments if they are passed in as unicode instead of str.
# Currently the strings in our tables just have ascii in them,
# so this ought to be safe.
def unicode_to_str(arg):
if isinstance(arg, unicode):
return str(arg)
else:
return arg
str_args = map(unicode_to_str, args)
self.cur.execute(sql, str_args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment