I need to change tables and variables dynamically from time to time, so I wrote the python method as follows:
selectQ ="""SELECT * FROM %s WHERE %s = %s;"""
self.db.execute(selectQ,(self.table,self.columnSpecName,idKey,))
return self.db.store_result()
However, this results in a syntax error. I tried debugging it to print the variables in the method and populate them manually, and it worked. So I'm not sure what I'm doing wrong?
Is it because I'm trying to use table replacement?
Also, how do I debug mysqldb so that it prints the substituted query as a string?
source
share