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
0
votes
1 answer

object str cannot be used in await expression in psycopg3

I have a function that copies a csv file to a database. I'm trying to do that asynchronously: import psycopg from config import config from pathlib import WindowsPath from psycopg import sql import asyncio async def main(): conn = await…
moth
  • 1,833
  • 12
  • 29
0
votes
0 answers

learning psycopg3 asyncio coroutine never awaited

I have been learning some examples here from psycopg3 https://www.psycopg.org/psycopg3/docs/advanced/async.html#with-async-connections , but none of them are working for me. First by running the examples the python interpreter complains that async…
moth
  • 1,833
  • 12
  • 29
0
votes
1 answer

How to connect to schema that is not public with psycopg 2 or 3

I cannot query from other schema's than public, also I am using supabase and connection string provided in supabase doesn't work.
dejoma
  • 394
  • 1
  • 6
  • 18
0
votes
0 answers

prepared statements in psycopg3

Are prepared statements written differently in psycopg3 than psycopg2? I am upgrading from psycopg2 to 3 and in psycopg2 this works but doesnt work for psycopg3 Also the variables name and age will be populated with data sql is a variable which is…
0
votes
0 answers

List of required parameters for a query

How can I obtain a list of required DBAPI2 named parameters (sqlite3, psycopg) from a parametrized query (without executing it and seeing error message)? Something like that: query1 = "select * from mytable where id = ':id' and name =…
pieca
  • 2,463
  • 1
  • 16
  • 34
0
votes
0 answers

python3 psycopg 'AsyncConnection' object has no attribute 'rowcount'

hello i have problem with psycopg asyn and pooler this my code : `async def checkmac(id): pool = AsyncConnectionPool("dbname=xx user=postgres password=xxx host=localhost port= 6543") async with pool.connection() as new : query =…
0
votes
0 answers

How to libpq copy into two tables concurrently in PostgreSQL?

I am listening to n different TCP streams and would like to copy the received data into n different tables after some simple post-processing. Latency is important, and using this approach sequentially I've managed to get insertions down to < 1…
user169291
  • 21
  • 2
0
votes
0 answers

Psycopg[binary] is turning my parameters into individual tuples rather than a single tuple

I am writing a basic banking app to keep my skills fresh and am trying to implement a transaction table into the mix to of course keep track of transactions. This happens as I am trying to insert a new transaction programmatically using Python and…
dmerc12
  • 1
  • 1
0
votes
1 answer

Using sqlalchemy with psycopg

I am in need of combining the results of a SQLAlchemy query and a pyscopg query. Currently I use psycopg to do most of my SQL selects in my code. This is done using a cursor and fetchall(). However, I have a separate microservice that returns some…
SoftwareThings
  • 304
  • 4
  • 15
0
votes
1 answer

How to handle BC (Before Christ) dates between PostgreSQL & Python via psycopg?

I understand that PostgreSQL has a larger date range allowing it to store BC dates, whereas Python goes to minimum year 1. What is a good way to insert/select such dates from PostgreSQL using psycopg? I'm wondering if I should just store the year as…
English Rain
  • 311
  • 5
  • 13
0
votes
1 answer

Working on new version of psycopg 3 and while installing psycopg[c] it wont install at all

I am working on psycopg 3 and not 2. Here is my code that I am trying to work on: from fastapi import FastAPI, Response, status, HTTPException from fastapi.params import Body from pydantic import BaseModel from typing import Optional from random…
0
votes
0 answers

Last line has an extra column while importing a CSV into postgresql wtih psycopg

I am trying to copy a CSV into a table using copy. I put all the corresponding fields in order and all rows are written successfully except for the last row. Where I get the error value too long for type character(1) CONTEXT: COPY temp_mls, line…
0
votes
1 answer

psycopg.errors.SyntaxError: syntax error at or near "ON" with execute

I'm using psycopg3 and PostgreSQL 14. When I run a copy or exec function, and include a ON argument, it gives me the error psycopg.errors.SyntaxError: syntax error at or near "ON" I have tried two different functions, both resulting in the same…
0
votes
0 answers

Psycopg3 returns None randomly

So i have a flask app, that connects to a Postgres12 DB using a user that just has select privileges. Often times i see my apis return 400 error, and api does this when the sql query executed returns None. I have built a small wrapper class over…
Dipendra bhatt
  • 729
  • 5
  • 14
0
votes
1 answer

how to use factory in psycopg3 register_composite?

In psycopg2, register_composite you can specify a factory parameter where: factory – if specified it should be a CompositeCaster subclass: use it to customize how to cast composite types found in…
ericshaaan
  • 251
  • 1
  • 3
  • 5