pola-rs / polars

Dataframes powered by a multithreaded, vectorized query engine, written in Rust
https://docs.pola.rs
Other
30.72k stars 2k forks source link

Transaction support for write database functions #17457

Closed jjmarchewitz closed 5 months ago

jjmarchewitz commented 5 months ago

Description

Pretty much the title. As a user, I would like some kind of interface/argument/object that lets me enter a transaction before doing a db write.

alexander-beedie commented 5 months ago

You should be able to handle that by beginning the transaction on your side before passing the connection object into write_database (which can take an instantiated connection object since a few versions ago, not just a URI).

We shouldn't be trying to manage transactions internally, as we can't know what your fallback logic should be, or if we're in the middle of some deeper set of nested transactions.

FYI: there's a PR about to merge that will further extend the types of connection objects we can handle, including additional ways of working with SQLAlchemy transactions (https://github.com/pola-rs/polars/pull/17470), though I don't believe you need to wait for it.

alexander-beedie commented 5 months ago

Closing, as this can (and should) be done user-side with an existing connection/session object 👌

(Note: https://github.com/pola-rs/polars/pull/17470 just merged, offering more connection/transaction handling options in the next Polars release, so can also be seen as closing this issue).

jjmarchewitz commented 4 months ago

Thank you! I didn't know that I could pass in connection objects now. Thanks :D