how to use multi variables in a single SQL python code

Viewed 51

I have used this code to use two variables in a single SQL code in Python :

cursor.execute("select * from customers WHERE username=%s and password=%s", (a, b))

but I've got this error :

MySQLInterfaceError: Python type tuple cannot be converted

though I've converted my strings into a tuple like this:

a = tuple(map(str, emaile.split(",")))
b = tuple(map(str, passe.split(",")))

how can I use these two variables in my cursor.execute code?

2 Answers
query = """select * from customers WHERE username=%s and password=%s"""
tuple1 = ("mini", 9000)
cursor.execute(query, tuple1)

cursor.execute("INSERT INTO table VALUES (%s, %s, %s)", (var1, var2, var3))

Related