add db_format_query

This commit is contained in:
Jude Nelson
2018-02-07 19:02:49 -05:00
parent 821e7d4d62
commit 47ffb6c655

View File

@@ -128,6 +128,14 @@ def db_query_execute(cur, query, values, abort=True, max_timeout=300):
raise e
def db_format_query( query, values ):
"""
Turn a query into a string for printing.
Useful for debugging.
"""
return "".join( ["%s %s" % (frag, "'%s'" % val if type(val) in [str, unicode] else val) for (frag, val) in zip(query.split("?"), values + ("",))] )
def daemonize(logfile):
"""
Double-fork and make a daemon.