8000 Fix missing **kwargs in adbc_driver_duckdb.dbapi.connect() by davlee1972 · Pull Request #16637 · duckdb/duckdb · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix missing **kwargs in adbc_driver_duckdb.dbapi.connect() #16637

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

Merged

Conversation

davlee1972
Copy link
Contributor
@davlee1972 davlee1972 commented Mar 13, 2025

Fixed missing **kwargs. Without kwargs connect() isn't following the adbc connect() standard and can't support additional options like autocommit..

>>> c = connect(autocommit=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: connect() got an unexpected keyword argument 'autocommit'

ADBC standard:

image

Python 3.9.20 (main, Oct  3 2024, 07:38:01) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import adbc_driver_duckdb
>>> import adbc_driver_manager<
8000
/span>
>>> import adbc_driver_manager.dbapi
>>>
>>>
>>> def connect(path: str = None):
...     """Connect to DuckDB via ADBC."""
...     db = None
...     conn = None
...     try:
...         db = adbc_driver_duckdb.connect(path)
...         conn = adbc_driver_manager.AdbcConnection(db)
...         return adbc_driver_manager.dbapi.Connection(db, conn)
...     except Exception:
...         if conn:
...             conn.close()
...         if db:
...             db.close()
...         raise
...
>>> c = connect(autocommit=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: connect() got an unexpected keyword argument 'autocommit'
>>>
>>> c = connect()
>>> c._autocommit
False
>>>
>>>
>>> def connect_fixed(path: str = None, **kwargs):
...     """Connect to DuckDB via ADBC."""
...     db = None
...     conn = None
...     try:
...         db = adbc_driver_duckdb.connect(path)
...         conn = adbc_driver_manager.AdbcConnection(db)
...         return adbc_driver_manager.dbapi.Connection(db, conn, **kwargs)
...     except Exception:
...         if conn:
...             conn.close()
...         if db:
...             db.close()
...         raise
...
>>> c_fixed = connect_fixed()
>>> c_fixed._autocommit
False
>>>
>>> c_fixed = connect_fixed(autocommit=False)
>>> c_fixed._autocommit
False
>>>
>>> c_fixed = connect_fixed(autocommit=True)
>>> c_fixed._autocommit
True
>>>

Fixed missing **kwargs
@davlee1972
Copy link
Contributor Author

Opened a issue for this. #16638

Copy link
Contributor
@Tishj Tishj left a comment

Choose a reason for hiding this comment

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

Thanks!

@Mytherin Mytherin merged commit 3b20963 into duckdb:main Mar 14, 2025
19 checks passed
@Mytherin
Copy link
Collaborator

Thanks!

krlmlr added a commit to duckdb/duckdb-r that referenced this pull request May 15, 2025
[Dev] Clean up and fix the CGroup memory/cpu limit discovery logic (duckdb/duckdb#16608)
Fix missing **kwargs in adbc_driver_duckdb.dbapi.connect() (duckdb/duckdb#16637)
Add Docker support for RISC-V CI with appropriate build commands (duckdb/duckdb#16549)
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request May 15, 2025
[Dev] Clean up and fix the CGroup memory/cpu limit discovery logic (duckdb/duckdb#16608)
Fix missing **kwargs in adbc_driver_duckdb.dbapi.connect() (duckdb/duckdb#16637)
Add Docker support for RISC-V CI with appropriate build commands (duckdb/duckdb#16549)
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request May 16, 2025
[Dev] Clean up and fix the CGroup memory/cpu limit discovery logic (duckdb/duckdb#16608)
Fix missing **kwargs in adbc_driver_duckdb.dbapi.connect() (duckdb/duckdb#16637)
Add Docker support for RISC-V CI with appropriate build commands (duckdb/duckdb#16549)
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request May 16, 2025
[Dev] Clean up and fix the CGroup memory/cpu limit discovery logic (duckdb/duckdb#16608)
Fix missing **kwargs in adbc_driver_duckdb.dbapi.connect() (duckdb/duckdb#16637)
Add Docker support for RISC-V CI with appropriate build commands (duckdb/duckdb#16549)
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request May 17, 2025
[Dev] Clean up and fix the CGroup memory/cpu limit discovery logic (duckdb/duckdb#16608)
Fix missing **kwargs in adbc_driver_duckdb.dbapi.connect() (duckdb/duckdb#16637)
Add Docker support for RISC-V CI with appropriate build commands (duckdb/duckdb#16549)
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

Successfully merging this pull request may close these issues.

3 participants
0