aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility/db_tools.py
diff options
context:
space:
mode:
authorLei Yan2013-07-12 22:58:39 +0000
committerLei Yan2013-07-12 22:58:39 +0000
commit155e2997613c0750de30b734686f8977524956f9 (patch)
treeaadc33054296834077d052975aa75065e756a9ac /wqflask/utility/db_tools.py
parent0feeb303cb1874cffd6e20f2758dcd578247bd54 (diff)
downloadgenenetwork2-155e2997613c0750de30b734686f8977524956f9.tar.gz
Rewrote code related to getting the tissue correlation column to display
Created new files for mrna assay tissue data and commonly used db query related functions
Diffstat (limited to 'wqflask/utility/db_tools.py')
-rw-r--r--wqflask/utility/db_tools.py15
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