-
I'm doing big bulk inserts into postgres, but can' figure out if/how databases exposes these methods? If its possible, please give me a hollar. Thanks - wg |
Beta Was this translation helpful? Give feedback.
Answered by
elivin
Jun 30, 2022
Replies: 1 comment
-
Hi I found one way to do it. There is a db = Database("postgresql+asyncpg://...")
# ...
async with db.connection() as connection:
await connection.raw_connection.copy_records_to_table(
"table_name",
columns=["id", "name"],
records=[
(1, "Record 1"),
(2, "Record 2"),
(3, "Record 3"),
],
) In this sample |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
tomchristie
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
I found one way to do it. There is a
raw_connection
property that returns the driver's current connection. It can be used like this:In this sample
connection.raw_connection
is an asyncpg.Connection object, so we can use all of its methods.