我正在尝试使用变量作为表名。我收到错误“...在第 1 行的 ''myTable'' 附近,我一定不能逃避这个权利。错误中的双 '' 似乎是一个线索,但我不明白。
db = MySQLdb.connect("localhost","user","pw","database" )
table = "myTable"
def geno_order(db, table):
cursor = db.cursor() # prepare a cursor object using cursor() method
sql = "SELECT * FROM %s"
cursor.execute(sql, table)
results = cursor.fetchall()