Skip to content

Tag: psycopg2

Inserting csv file into a database using Python

In Python I’ve connected to a Postgres database using the following code: I have created a table called departments and want to insert data into the database from a CSV file. I read the csv in as follows: And I am trying to insert this data into the table with the following code: which I’ve seen d…

psycopg2 SyntaxError with time or date

I have a code that automatically identifies for what table, which columns and what the values to parse into sql insert statement. It works well with all of my tables, except only one. This is a structure of the model of this table: I got SyntaxError only with this table. My insertion statement: This is an err…