diff options
author | Zachary Sloan | 2013-09-13 14:30:20 -0500 |
---|---|---|
committer | Zachary Sloan | 2013-09-13 14:30:20 -0500 |
commit | 261c7852ceaecf2034923ef1c4ec1481db786edd (patch) | |
tree | a0c9c9da9849f8693e746f6d80a715018e0c0da6 /wqflask/utility/db_tools.py | |
parent | 20be011f8b33fcde94037af19e403d3b76d5c9d1 (diff) | |
parent | af24c0d610d9a2189f86677e4f23deb372ee2bf7 (diff) | |
download | genenetwork2-261c7852ceaecf2034923ef1c4ec1481db786edd.tar.gz |
Merge /home/lei/gene
Diffstat (limited to 'wqflask/utility/db_tools.py')
-rw-r--r-- | wqflask/utility/db_tools.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/wqflask/utility/db_tools.py b/wqflask/utility/db_tools.py new file mode 100644 index 00000000..4034f39c --- /dev/null +++ b/wqflask/utility/db_tools.py @@ -0,0 +1,15 @@ +from __future__ import absolute_import, print_function, division + +from MySQLdb import escape_string as escape + +def create_in_clause(items): + """Create an in clause for mysql""" + in_clause = ', '.join("'{}'".format(x) for x in mescape(*items)) + in_clause = '( {} )'.format(in_clause) + return in_clause + +def mescape(*items): + """Multiple escape""" + escaped = [escape(str(item)) for item in items] + #print("escaped is:", escaped) + return escaped |