0
votes

My table is sqlite3 is created with the following:-

'CREATE TABLE IF NOT EXISTS gig_program ( gig_program_id VARCHAR(20) PRIMARY KEY );'

When I try to insert data into the table using python 3.8 with the following:-

sql = 'INSERT INTO gig_program ( gig_program_id ) VALUES ( "20200524120727" );'

cur.execute(sql)

the following exception was thrown:-

near "gig_program": syntax error

When I cut and past the insert command to the sqlite3 console, it works.

I have also tried using another editor for the program (thinking that there may be hidden characters) but the result is the same.

I would appreciate help. I have used similar methods in other parts of the program to insert data and they work without issue.

1
If you use sql = 'INSERT INTO gig_program ( gig_program_id ) VALUES ( \'20200524120727\' );' Does it work? - Lajos Arpad
Your code works for me. - mechanical_meat

1 Answers

0
votes

Thank you for looking into my questions.

I found that it was actually my mistake. The exception was actually for a second sql statement which I missed out the "FROM" word.

Thank you everyone for your time.

Hope everyone is doing well.