Search code examples
pythoncursor

python cursor FROM %s


I try to execute this request :

cur.execute("SELECT MAX(id) FROM %s WHERE equipement_id = %s", (table,eq_id))

But i have error because the FROM %s is not build correctly.


Solution

  • Try like this

    cur.execute("""SELECT MAX(id) FROM %s WHERE equipement_id = %s""" % (table, eq_id))