aboutsummaryrefslogtreecommitdiff
path: root/wqflask/utility/db_tools.py
blob: 92bde5052d70194c0617b7d77a6ef818bcbb47ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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