Psycopg3 supports async connections and async cursors. I have multiple writer tasks writing to a database. Should I pass each of those tasks the same AsyncConnection
? If not, should I pass them the same AsyncCursor
? Or should I make a new connection in each of the functions?
eg: below, would I send aconn
to each of my tasks? Or cur
? Or should this code be in each of the tasks?
async with await psycopg.AsyncConnection.connect() as aconn:
async with aconn.cursor() as cur:
await cur.execute(...)
All of the example code I could find had only one task being created. Thanks!