Skip to main content

All Questions

1 vote
0 answers
51 views

How to use SQL Stored Procedures for dynamic tables in sqlalchemy with psycopg2

I need execute SQL query for different dynamic tables. I try to do it as follows: import sqlalchemy.pool as pool def get_conn_pool(): conn = psycopg2.connect(user=settings.POSTGRES_USER, password=...
Vadim's user avatar
  • 464
0 votes
0 answers
36 views

Update created engine in sqlacemy

I've created database using the following code: from sqlalchemy import create_engine, text db_user = 'postgres' db_password = 'chnageme' db_host = '12.123.123.123' db_port = '5432' db_name = 'new_db' ...
Gооd_Mаn's user avatar
  • 1,076
0 votes
0 answers
269 views

Rewriting psycopg2 code using cursor.copy_expert() in SQLAlchemy 2.0+ based on psycopg 3

I have to migrate this code snippet to psycopg (version 3), ideally using it through SQLAlchemy 2.0+: from io import StringIO import psycopg2 conn = psycopg2.connect(**dbconfig) curs = conn.cursor() ...
swiss_knight's user avatar
  • 8,051
0 votes
0 answers
106 views

Psycopg hangs on connection

Running the latest (3.2.1) version of th psycopg faced a problem that it hangs on getting connection from the pool to the postgres db. I saw that timeout there is 0.1 so it must raise an error but ...
Andrew's user avatar
  • 404
0 votes
1 answer
237 views

SQLAlchemy - psycopg2.errors.InvalidSchemaName: no schema has been selected to create in

I am connecting a FastAPI and SQLAlchemy app to a postgres deployment using kubernetes. I am specifying my connection string and schema as follows: DB_URL = f"postgresql+psycopg2://{POSTGRES_USER}...
jm22b's user avatar
  • 435
1 vote
0 answers
69 views

No module named 'src', even if it exists

I have a repository project, which is taking me longer than I expected to setup both database and the task (a cron job) both in a smooth way. To test connection, first run the postgres server then ...
Bruno Henrique Peixoto's user avatar
0 votes
0 answers
36 views

SQLAlchemy engine initialization aborts

I wrote a small Class for database interaction in my application. however any attempt to create an instance of the Class results in the following error free(): double free detected in tcache 2 Aborted ...
P.R.F.'s user avatar
  • 33
1 vote
0 answers
154 views

Can I pass extra arguments into the panda to_sql method callable?

I've been looking at the Pandas Docs and Pandas Source code of pandas to pass big CSV tables into my PostgreSQL DB in the fastest way possible. Using pandas.DataFrame.to_sql using a Callable method &...
Corina Roca's user avatar
0 votes
0 answers
134 views

sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation)

I came across similar questions to IntegrityError sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation) but none of those answer my question. I have models.py: class UsersT(db.Model): ...
Divya Prattipati's user avatar
0 votes
2 answers
188 views

"No function matches the given name and argument types." when trying to insert a `DateTimeTzRange` with Sqlalchemy ORM

I've got a database table in a Postgres 15 database, it's got two columns (amongst others), one is of type daterange, the other is tstzrange. We've got some code that inserts to this table with raw ...
Greg B's user avatar
  • 14.9k
0 votes
1 answer
199 views

Getting an error of No module named 'psycopg2' when using Testcontainers-postgres in Python

I have a session.py file that looks like this: """Session module to create a session for the PostgreSQL database.""" from os import environ # pylint: disable=no-name-in-...
Asad Amir Khwaja's user avatar
0 votes
0 answers
52 views

bulk insert data into table where cell can be empty string for a column that is part of a composite primary key, using psycopg3

I have the following table - note there is a composite primary key consisting of 5 columns. test_ts = Table('test_ts', meta, Column('metric_id', ForeignKey('metric.id'), primary_key = True), ...
mike01010's user avatar
  • 6,098
0 votes
0 answers
141 views

SQLAlchemy: duplicate key violation because of old record that I delete in same session

I currently have a User table (with some child tables). Upon doing a POST request, I'm trying to see if a user already exists, if so delete that user, and create a new User object/table (with the ...
bartolini's user avatar
0 votes
1 answer
73 views

"psycopg2.OperationalError" - I connect through pgadmin without any problems, and through psycopg2

The container is deployed in the docker. I've tried different ways, nothing helps. What could be the problem? Could something from the outside be creating a problem? services: db: ...
Zalim's user avatar
  • 1
1 vote
1 answer
533 views

Is this expected behavior for Python Datetime with timezone inserted into Postgres DB using sqlalchemy orm? What's going on?

Summary Inserting datetime with timezone object into postgres column without timezone appears to first convert to a local timestamp and then removes the offset. Eg for 2024-01-15 19:04:38.921936+00:00 ...
Heath's user avatar
  • 138

15 30 50 per page
1
2 3 4 5
15