This question already has an answer here:
- Escaping chars in Python and sqlite 3 answers
I am trying to insert data into database using sqlite in python. Now when I have a single quote in my variable, it gives error like
data = "This is my apple's seed."
cursor.execute("insert into tableName (ColName) values ('%s')" %data)
sqlite3.OperationalError: near "s": syntax error
I know that this problem occurred because I didn't escape characteres properly. How do I do that?
Aucun commentaire:
Enregistrer un commentaire