I have written a python queries with DuckDB:
import duckdb
con = duckdb.connect()
con.query('CREATE TABLE people(id INTEGER, name VARCHAR);')
con.query('INSERT INTO people VALUES (1, 'Mark'), (2, 'Hannes')')
But receive an error message:
con.query('INSERT INTO people VALUES (1, 'Mark'), (2, 'Hannes')') ^ SyntaxError: invalid syntax. Perhaps you forgot a comma?
As I understand the problem is with ordinary quote, which DB don`t see. How can I solve this problem?
I`m expecting to make insert query.
Python has two different quotes you can use for strings - single (') and double (")
So you can write code like this:
con.query("INSERT INTO people VALUES (1, 'Mark'), (2, 'Hannes')")
or escape the internal quotes, like this:
con.query('INSERT INTO people VALUES (1, \'Mark\'), (2, \'Hannes\')')