-
We have a few places in our codebase where we have code like: let obj_foo = create_object_of_type_foo();
let obj_foo2 = create_object_of_type_foo();
let obj_bar = create_object_of_type_bar();
obj_foo.insert(db).await?;
obj_foo2.insert(db).await?;
obj_bar.insert(db).await?; How can I make the calls in bulk?
The equivalent in sqlalchemy would be: # There's an add_all equivalent too, but the point is: these don't actually call the db
db.add(obj_foo)
db.add(obj_foo2)
db.add(obj_bar)
# Actually makes the call to the db:
await db.flush()
# This both commits the transaction and flushes (no need to explicitly flush
await db.commit() |
Beta Was this translation helpful? Give feedback.
Answered by
billy1624
Feb 1, 2022
Replies: 1 comment 2 replies
-
Hey @tasn, I believe you can perform bulk insert for the first two inserts mentioned above. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
tasn
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @tasn, I believe you can perform bulk insert for the first two inserts mentioned above.
See https://www.sea-ql.org/SeaORM/docs/basic-crud/insert#insert-many