Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Rust and Polars with Postgres #4842

Closed
2 tasks done
spirrello opened this issue Sep 13, 2022 · 6 comments
Closed
2 tasks done

Using Rust and Polars with Postgres #4842

spirrello opened this issue Sep 13, 2022 · 6 comments

Comments

@spirrello
Copy link

Research

  • I have searched the above polars tags on StackOverflow for similar questions.

  • I have asked my usage related question on StackOverflow.

Link to question on StackOverflow

https://stackoverflow.com/questions/73697218/how-to-use-polars-with-rust-and-postgres

Question about polars

Where can I find an easy to follow guide such as the following for Python? There doesn't seem to be anything for Rust.

https://pola-rs.github.io/polars-book/user-guide/howcani/io/postgres.html

@huang12zheng
Copy link
Contributor

  • read
    I just want show code for you:
# https://github.com/pola-rs/polars/blob/master/py-polars/polars/io.py#L1018
def read_sql(
# ...
if _WITH_CX:
        tbl = cx.read_sql(
            conn=connection_uri,
            query=sql,
            return_type="arrow2",  //<<<
            partition_on=partition_on,
            partition_range=partition_range,
            partition_num=partition_num,
            protocol=protocol,
        )
        return from_arrow(tbl)

That is to say, you need ConnectorX to import data from DB into DataFrame(arrow) high speed
I'm not sure about that

from_arrow in rust maybe is DataFrame:try_from :
// https://github.com/pola-rs/polars/blob/9991a0dd81c0e71a054b52e5f801579fc260e4c7/polars/polars-core/src/frame/from.rs

  • write
    It should be consistent with DOC

@spirrello
Copy link
Author

spirrello commented Sep 13, 2022 via email

@huang12zheng
Copy link
Contributor

huang12zheng commented Sep 13, 2022

@spirrello
I looked again and found the Connector-X, which is write by rust
https://github.com/sfu-db/connector-x
So I think you can actually do that with Rust.

@huang12zheng
Copy link
Contributor

what's more
https://github.com/sfu-db/connector-x/blob/main/connectorx/tests/test_polars.rs
let df: DataFrame = destination.polars().unwrap();
I think you can solve it directly with ConnectorX

and, some other issue Related to this one:
#3540
#2994

@spirrello
Copy link
Author

@huang12zheng Thank you so much for sharing these. I'll look these over today or tomorrow.

@zundertj
Copy link
Collaborator

zundertj commented Oct 2, 2022

Closing as the question has been answered.

@zundertj zundertj closed this as completed Oct 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants