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

feat(python): Support use of SQLAlchemy "Connectable" in write_database #17470

Merged
merged 3 commits into from
Jul 8, 2024

Conversation

phi-friday
Copy link
Contributor

pandas supports sa.engine.Connectable.
Passing sa.engine.Connectable allows the user to control the transaction.

@github-actions github-actions bot added fix Bug fix python Related to Python Polars labels Jul 7, 2024
Copy link

codecov bot commented Jul 7, 2024

Codecov Report

Attention: Patch coverage is 57.14286% with 3 lines in your changes missing coverage. Please review.

Project coverage is 80.49%. Comparing base (ad836bd) to head (7c5ae5e).
Report is 1 commits behind head on main.

Files Patch % Lines
py-polars/polars/dataframe/frame.py 57.14% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #17470      +/-   ##
==========================================
- Coverage   80.49%   80.49%   -0.01%     
==========================================
  Files        1483     1483              
  Lines      195010   195013       +3     
  Branches     2781     2782       +1     
==========================================
- Hits       156972   156969       -3     
- Misses      37527    37532       +5     
- Partials      511      512       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alexander-beedie alexander-beedie changed the title fix(python): Passthrough sa Connectable feat(python): Support use of SQLAlchemy "Connectable" in write_database Jul 7, 2024
@github-actions github-actions bot added the enhancement New feature or an improvement of an existing feature label Jul 7, 2024
@alexander-beedie alexander-beedie removed the fix Bug fix label Jul 7, 2024
@alexander-beedie
Copy link
Collaborator

I will double-check tonight (on mobile at the moment), but from what I can see this looks like a good addition; thanks!

Copy link
Collaborator

@alexander-beedie alexander-beedie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's version-gate the tests, as they don't work on earlier versions of SQLAlchemy. (I will typically run DB tests with both versions locally, as not everyone has moved to v2.0 yet). The two suggested changes also require the additional import from polars._utils.various import parse_version at the top of the test module.

Otherwise, looks good to me 👍

@phi-friday phi-friday force-pushed the fix-support-sa-connection branch from c364d73 to 7c5ae5e Compare July 7, 2024 15:44
@phi-friday
Copy link
Contributor Author

Since it's entirely up to the user to control the transaction, I decided it was okay to just modify the test.

@phi-friday
Copy link
Contributor Author

phi-friday commented Jul 7, 2024

This is unrelated to this pr, but when I lowered the versions of sqlalchemy<2 and pandas<2.2, I got 3 errors.

FAILED tests/unit/interchange/test_roundtrip.py::test_from_dataframe_pandas_timestamp_ns - AssertionError: DataFrames are different (value mismatch for column 'a')
FAILED tests/unit/io/database/test_read.py::test_read_database_parameterised - sqlalchemy.exc.RemovedIn20Warning: Deprecated API features detected! These feature(s) are not co...
ERROR tests/unit/io/database/test_async.py

I know that async_sessionmaker can be replaced with sessionmaker starting with a certain version, but I don't remember which version.

@alexander-beedie
Copy link
Collaborator

alexander-beedie commented Jul 8, 2024

Since it's entirely up to the user to control the transaction, I decided it was okay to just modify the test.

Even better; we'll have coverage for both versions ;)

@alexander-beedie alexander-beedie merged commit e713045 into pola-rs:main Jul 8, 2024
14 checks passed
@phi-friday phi-friday deleted the fix-support-sa-connection branch July 8, 2024 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or an improvement of an existing feature python Related to Python Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants