Skip to content
Advertisement

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 done in various articles

Is connect_timeout a valid URL parameter acquiring a connection via Peewee’s playhouse.db_url.connect?

I’m using Peewee as ORM and connect to a Postgres database (psycopg2) using the Playhouse extension db_url.connect. My URL is a vanilla postgresql://username:pass@host:port/dbname?options=… so not using pooling or anything advanced at the moment. Some times when I call connect it hangs for a long time and doesn’t come back. So I appended to my database URL the parameter &connect_timeout=3 meaning

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 error: It’s says in

OpenTelemetry is not tracing SQL Statements while using cursor_factory as NamedTupleCursor

Kindly look at the code below. I’m using opentelemetry for tracing. Psycopg2Instrumentor for PostgreSQL tracing. Here only the “show server_version” SQL statement is getting traced. But the SQL statement in execute method is not traced. I think it’s because of using NamedTupleCursor cursor_factory. If I remove NamedTupleCursor, it’s tracing the main SQL statements. Could you please help me to trace

django.db.utils.DataError: value too long for type character varying(30). I am getting this error while migrating on heroku postgresql

The errors I am getting while migrating on PostgreSQL Heroku. Note: It is working fine on the local server. there is no column with 30 lengths even tried migrating after deleting all data and still getting the same error. This is the model of the project models.py Answer I just deleted the junk file inside the migrations>pycache

Advertisement