I am trying to insert the lines read from a file into the sqlite database in Python. Lines have spaces (newlines, tabs, and spaces), and also have single or double quotation marks. Here is how I am trying to do this:
import sqlite3 conn = sqlite3.connect('example.db') c = conn.cursor()
I found that this is an error with the error:
c.execute("INSERT INTO test VALUES ('%s', 'bar')" %(testfield)) sqlite3.OperationalError: near "world": syntax error
How can i achieve this? Do i need to escape the lines before inserting into db, and if so, how? thanks.
python sql database mysql sqlite
user248237dfsf
source share