peewee-async
peewee-async copied to clipboard
Can we got a connection from pool and set isolation level only for this connection?
At now use different lsolation_level should do it in global.
database = PooledPostgresqlDatabase(
**config.database_conf,
autoconnect=True,
autorollback=True,
max_connections=10,
isolation_level=ISOLATION_LEVEL_REPEATABLE_READ
)
pg_objects = Manager(database=database, loop=loop)
objects = await pg_objects.execute(q)
Can we got connection from pool and set isolation level only for this connection. After the connection done remove this connection:
async with db.pg_objects.connection() as conn:
conn.set_isolation_level()
.........
This snippet should work for you.
async with db.pg_objects.pool.acquire() as conn:
conn.set_isolation_level()