Python - Sqlite - OperationalError: near "s": syntax error

Viewed 7352

I'm getting the following error when trying to add value to a table:

line 33, in insert
    c.execute("INSERT INTO {tn} (Process, Info) VALUES('{proc}', 
'{inf}')".format(tn=table_name, proc=proc, inf=content))
OperationalError: near "s": syntax error

This is happening when using certain text, if I write something regular there is no issue, but for example something like that:

#. My item number one
#. My item number two with some more content
    and it's continuing on the second line?
#. My third item::
    Oh wait, we can put code!
#. My four item::
    No way.
.. _bottom:
    Go to top_'''

It is failing.. This is the code I am using:

def insert(table_name, proc, content):

    conn = sqlite3.connect(sqlite_file)
    conn.text_factory = str
    c = conn.cursor()

    c.execute("INSERT INTO {tn} (Process, Info) VALUES('{proc}', 
              '{inf}')".format(tn=table_name, proc=proc, inf=content))

    conn.commit()
    conn.close()

Appreciate your help guys :)

1 Answers
Related