Skip to content

fix(python): Support for ADBC drivers instantiated with dbc in DataFrame.write_database#26157

Merged
nameexhaustion merged 3 commits intopola-rs:mainfrom
henryharbeck:dbc-driver
Mar 10, 2026
Merged

fix(python): Support for ADBC drivers instantiated with dbc in DataFrame.write_database#26157
nameexhaustion merged 3 commits intopola-rs:mainfrom
henryharbeck:dbc-driver

Conversation

@henryharbeck
Copy link
Contributor

@henryharbeck henryharbeck commented Jan 19, 2026

Closes #26103
Supersedes #25889 (thanks @0x0Aro)

write_database used to assume that an instantiated ADBC connections had a corresponding Python package for the driver installed. With the recently released dbc cli, this is no longer required.

This is not specifically tested in CI, as the dbc cli is not installed there. The changes have been verified locally.


Repro

Install dbc and add postgresql (in the example here)

uv tool install dbc
dbc install postgresql

Script

from adbc_driver_manager import dbapi
import polars as pl

def main():
    df = pl.DataFrame({"a": [1, 2, 3], "b": ["x", "y", "z"]})

    uri = "postgresql://postgres:postgres@localhost:5432"
    with dbapi.connect("postgresql", uri=uri) as conn:
        df.write_database("my_table", conn, if_table_exists="replace")
        # Prove the data was written
        out = pl.read_database("SELECT * FROM my_table", conn)
        print(out)

if __name__ == "__main__":
    main()

Before: raises even though an instantiated connection is passed to write_database

ModuleNotFoundError: ADBC 'adbc_driver_postgresql' driver not detected.
If ADBC supports this database, please run: pip install adbc-driver-postgresql

After:

shape: (3, 2)
┌─────┬─────┐
│ a   ┆ b   │
│ --- ┆ --- │
│ i64 ┆ str │
╞═════╪═════╡
│ 1   ┆ x   │
│ 2   ┆ y   │
│ 3   ┆ z   │
└─────┴─────┘

@github-actions github-actions bot added A-io-database Area: reading/writing to databases fix Bug fix python Related to Python Polars labels Jan 19, 2026
@henryharbeck henryharbeck changed the title fix(python): Support for ADBC drivers instantiated with dbc in write_database fix(python): Support for ADBC drivers instantiated with dbc in DataFrame.write_database Jan 19, 2026
@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.66%. Comparing base (9d60226) to head (a3fe4f4).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
py-polars/src/polars/dataframe/frame.py 71.42% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #26157      +/-   ##
==========================================
+ Coverage   81.00%   81.66%   +0.66%     
==========================================
  Files        1805     1805              
  Lines      248021   248024       +3     
  Branches     3132     3131       -1     
==========================================
+ Hits       200902   202551    +1649     
+ Misses      46313    44668    -1645     
+ Partials      806      805       -1     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ritchie46
Copy link
Member

@alexander-beedie can you review?

@alexander-beedie
Copy link
Collaborator

alexander-beedie commented Jan 20, 2026

@alexander-beedie can you review?

@ritchie46 No problem, will get on it tomorrow - this renewed ADBC driver push from the Columnar folks is likely to become relevant with things I'm doing at work too 🤔

@alexander-beedie
Copy link
Collaborator

alexander-beedie commented Jan 27, 2026

Finally started reviewing (apologies for the delay); so far, so good. Will run a few local experiments (at home tonight) and merge tomorrow if all is well 👍

@alexander-beedie alexander-beedie self-assigned this Jan 27, 2026
@henryharbeck
Copy link
Contributor Author

Let me know how you get on @alexander-beedie
Happy to talk through the change or provide examples for any other databases/drivers

And sorry for the ping - just keen to get this in the next release!

@henryharbeck
Copy link
Contributor Author

@alexander-beedie - friendly ping. Your review would be greatly appreciated.
Is a small fix so shouldn't be too much effort to review

@0x0Aro
Copy link

0x0Aro commented Feb 27, 2026

@henryharbeck Hi. Sorry for the late response, I've been watching this change closely for the recent couple weeks now. Since it is yet to be merged, would it be possible for I to take it back? It means a lot as a first time open source contributor. Appreciate your time in this change.

@nameexhaustion nameexhaustion merged commit 45c9157 into pola-rs:main Mar 10, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-io-database Area: reading/writing to databases fix Bug fix python Related to Python Polars RC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

write_database assumes a Python adbc-driver-... package is installed but dbc foundry is moving away from that

5 participants