polars icon indicating copy to clipboard operation
polars copied to clipboard

rust-polars SQL read and write

Open rhobro opened this issue 2 years ago • 8 comments

pandas as py-polars seem to have read_sql methods allowing reading tables into a dataframe.

Would it be possible for rust polars to also allow reading of sql query results into a dataframe and also to insert dataframe rows to the database?

It could use an integration with sqlx to allow support with many types of database.

rhobro avatar May 31 '22 09:05 rhobro

This would be similar to pandas.to_sql

rhobro avatar May 31 '22 16:05 rhobro

Related: https://github.com/pola-rs/polars/issues/2994. Note that connectorx (which polars.read_sql can use) does have a Rust query API: https://docs.rs/connectorx/latest/connectorx/

alexander-beedie avatar Jun 01 '22 08:06 alexander-beedie

What is the status of this request please?

romanzdk avatar Mar 03 '23 22:03 romanzdk

Is there no way of reading from a SQL server into a DF? In python I made a ODBC connection and used that to make a DF. One would think I could do the same thing in the RUST version...

MatsRivel avatar Sep 26 '23 13:09 MatsRivel

hey, I have a similar requirement. Currently I use odbc-api to get data from an DB2 (IBM i) database . I tried to use arrow-odbc but I didn't find a way to create a polars DataFrame from arrow RecordBatch. It would be really nice if some thing like the python from_arrow function could be implemented in the Rust API. Or maybe I didn't find a simple way to do it? Thanks and Cheers!

sportfloh avatar Nov 19 '23 20:11 sportfloh

I just wanted to check in on this. Is there work already underway on this? I'd be more than happy to help if this would be a welcome contribution.

paulstey avatar Jan 09 '24 02:01 paulstey

I can't live without pandas.read_sql so this is something I would love to see in the Rust API.

mschmill avatar Jan 09 '24 19:01 mschmill

Hi, here is my current solution with arrow_odbc, arrow, polars_arrow. https://github.com/pacman82/odbc-api/discussions/536#discussioncomment-8807348

I found the arrow RecordBatch to DataFrame code hiere: https://stackoverflow.com/questions/78084066/arrow-recordbatch-as-polars-dataframe

sportfloh avatar Mar 15 '24 21:03 sportfloh