+ 2
Variables in SQL
Python for Sql database: Connection to database and so on... Variable = * Variable2 =.... cursor.execute("SELECT Variable FROM table WHERE Variable2....") I cant figure out, how to use variables in the sql-statement.
3 Respuestas
+ 3
Go to the link below, and scroll a bit, you'll get your answer.
Happy coding <^_^>
https://pynative.com/JUMP_LINK__&&__python__&&__JUMP_LINK-sqlite-insert-into-table/#:~:text=You%20can%20take%20those%20values,used%20for%20parameters.
+ 1
import mysql
import mysql.connector
...
...
SearchString= "somestring"
Query = """SELECT *
FROM table WHERE category = %s """
cursor.execute(Query , (SearchString))
What's wrong with my code? I have also tried: '%s', "%s" ...
Any ideas, anyone?
+ 1
got it 1min later:
cursor.execute("SELECT * FROM table WHERE category = '%s'",% searchstring)
hope, it's helpful to someone in the future