I need to dynamically change tables and variables from time to time, so I wrote a python method like this:
selectQ =\"\"\"SELECT * FROM %s WHERE %s = %s
Here is a full working example
def rtnwkpr(tick, table, col): import MySQLdb as mdb tickwild = tick + '%' try: con = mdb.connect(host, user, password, db); cur = con.cursor() selectq = "SELECT price FROM %s WHERE %s LIKE %%s;" % (table, col) cur.execute(selectq,(tickwild)) return cur.fetchall()