Questions tagged [psycopg3]

Use this tag for questions about the psycopg3 Postgresql connector package for Python, a new implementation of the psycopg2 package.

psycopg3 is a new implementation of the Postgresql connector for Python.

External links

70 questions
1
vote
0 answers

Quart and psycopg3 AsyncConnection notifies() -> SSE multiple clients

I am trying to create an SSE server Quart application that listens to notifications from a postgresql instance (and then sends an SSE message to registered EventSources). Have gotten a simplified version of…
David I
  • 31
  • 1
  • 5
1
vote
2 answers

postgres / psycopg: Date format error importing CSV

I'm using psycopg (v3) in python 3.10, working in Pycharm. I made a table and am trying to import a .csv; I'm getting this error: invalid input syntax for type date: "01/31/22" CONTEXT: COPY test_table, line 1, column quote_date: "01/31/22" First…
dbkc
  • 13
  • 3
0
votes
1 answer

Django save() with specified psycopg connection

I have made a class called Database that I use to manage a connection to a Postgres database via psycopg3. This enables me to do things like: db = Database(postgres_connection_data) class_one_instance.insert(insert_data,…
0
votes
0 answers

How do I get psycopg_pool to connect to my Cockroach Database Cluster using psycog.crdb.connect which is supported in psycopg 3.1?

I'm using psycopg_pool (3.1.7) and would like to connect to a Cockroach Database Cluster. psycopg 3.1 has support for CRDB via psycopg.crdb.connect(), but I'm unsure how to get psycopg_pool to use psycopg.crdb.connect() rather than…
Ron
  • 437
  • 3
  • 12
0
votes
0 answers

Unable to install Psycopg-c [Preparing metadata (pyproject.toml) did not run successfully]

**(venv) [xxxx@rocky4 ~]$ pip install psycopg-c** Collecting psycopg-c Using cached psycopg-c-3.1.9.tar.gz (538 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ...…
0
votes
0 answers

Insert pandas dataframe to an SQL table that has user defined enum types using psycopg 3

I need to insert some data into a table, and I have many user defined enum types there. I have the data in a pandas dataframe. How can I insert my data. A simplified version: The type and the table is defined in PostgreSQL like that: CREATE TYPE…
0
votes
1 answer

Psycopg3: How to use Identifier in executemany()

I'm trying in python to use psycopg (version 3.1.4) to truncate a lot of tables with executemany(), but can't figure out what to use as a placeholder in the query. The documentation doesn't really say anything on this as far as I can see. My code…
AstridNeu
  • 31
  • 3
0
votes
1 answer

Get column names using COPY query TO STDOUT with psycopg3

How can I get the column names when getting data using psycopg3 with COPY TO STDOUT feature, f.e. copy (select a, b, c, from t1 join t2 using (t1_id) where not t1.is_test) to STDOUT feature? Because this is not simple select from a table, I cannot…
lospejos
  • 1,976
  • 3
  • 19
  • 35
0
votes
1 answer

Trying to form a Multirange with two Range objects

According to the docs, https://access.crunchydata.com/documentation/psycopg3/3.1.4/ The psycopg3 Range is: Range objects are immutable, hashable, and support the in operator (checking if an element is within the range). However in Python I would…
Mark G
  • 27
  • 5
0
votes
0 answers

Connections leak from a Psycopg connection pool

Connections leak with resulting timeout error at the connection get. I am using connection pool configured as follows: from psycopg_pool import ConnectionPool pool = ConnectionPool(conninfo=config['postgres']['url']) @atexit.register def…
Dmitry
  • 727
  • 1
  • 8
  • 34
0
votes
2 answers

Why psycopg cursor.fecthone return a list of None if no row was hit from select query?

My function to query account by email: CREATE FUNCTION get_account_by_email(account_email varchar(64)) RETURNS account AS $$ SELECT id, name, email FROM account WHERE account.email = account_email; $$ LANGUAGE SQL; My python code to call…
timewalker
  • 29
  • 7
0
votes
1 answer

Setting up a Connection db utility using psycopg3

I have this db_utils.py section where I define newconnect(): def newconnect(): with psycopg.connect("host=aaa port=5432 dbname=ccc user=bbb password=xxx") as conn: print("Connected") cur = conn.execute('SELECT version()') db_version…
Mark G
  • 27
  • 5
0
votes
0 answers

Is the psycopg connection already encrypted or does it require any additional encryption solution?

I need to connect thought the Internet to PostgreSQL with psycopg and Python. My question is: Does the psycopg connection already encrypted and safe to transmit sensitive data without additional encryption (SSH, VPN)?
vasili111
  • 6,032
  • 10
  • 50
  • 80
0
votes
1 answer

writing to postgresql database with geopandas using psycopg and sqlalchemy

I have credentials to an online postgresql server defined as following: database=db, host_db=url_to_server, db_port=5432, db_user=username, db_password=pwd, I want to connect to the server to read and write data using pandas/geopandas in python. The…
0
votes
2 answers

How can I connect to remote database using psycopg3

I'm using Psycopg3 (not 2!) and I can't figure out how can I connect to a remote Postgres server psycopg.connect(connection_string) https://www.psycopg.org/psycopg3/docs/ Thanks!
Alon Barad
  • 1,491
  • 1
  • 13
  • 26