Skip to content

Conversation

@lidavidm
Copy link
Member

@lidavidm lidavidm commented Oct 7, 2025

  • Allow positional driver argument.
  • Allow URI as a toplevel argument given that it is fairly common.
  • Infer driver/URI argument if given a URI-like string as the driver argument.

Closes #3517.

@lidavidm lidavidm requested review from amoeba and ianmcook October 7, 2025 04:05
@lidavidm
Copy link
Member Author

lidavidm commented Oct 7, 2025

IMO, if we want to add this to the Rust driver manager, the behavior should not be magic and instead we should add ManagedDriver::load_dynamic_from_uri.

@lidavidm lidavidm marked this pull request as ready for review October 7, 2025 07:45
@lidavidm lidavidm requested a review from zeroshade as a code owner October 7, 2025 07:45
@github-actions github-actions bot added this to the ADBC Libraries 21 milestone Oct 7, 2025
Copy link
Member

@amoeba amoeba left a comment

Choose a reason for hiding this comment

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

This looks good but I ran into one issue. If you do something like,

dbapi.connect("sqlite://games.sqlite")

The correct driver is detected but, since the full URI string is passed unmodified as the "uri", and I assume the ADBC SQLite driver passes that through, you get,

adbc_driver_manager.OperationalError: IO: failed to open 'sqlite://games.sqlite': failed to allocate memory

Ultimately, sqlite itself doesn't handle such URIs so I don't think any change is needed but I thought I'd point it out in case you had any good ideas. Other drivers, such as postgresql, handle the unmodified URIs just fine.

For example, "adbc_driver_sqlite" will first attempt to load
adbc_driver_sqlite.toml from the various search paths. Then, it
will try to load libadbc_driver_sqlite.so on Linux,
libadbc_driver_sqlite.dylib on MacOS, or adbc_driver_sqlite.dll on
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
libadbc_driver_sqlite.dylib on MacOS, or adbc_driver_sqlite.dll on
libadbc_driver_sqlite.dylib on macOS, or adbc_driver_sqlite.dll on

libadbc_driver_sqlite.dylib on MacOS, or adbc_driver_sqlite.dll on
Windows. See :doc:`/format/driver_manifests`.
- A full path to a shared library to load.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
- A full path to a shared library to load.
- A relative or absolute path to a shared library to load.

Is this right?

@lidavidm
Copy link
Member Author

This looks good but I ran into one issue. If you do something like,

dbapi.connect("sqlite://games.sqlite")

The correct driver is detected but, since the full URI string is passed unmodified as the "uri", and I assume the ADBC SQLite driver passes that through, you get,

adbc_driver_manager.OperationalError: IO: failed to open 'sqlite://games.sqlite': failed to allocate memory

Ultimately, sqlite itself doesn't handle such URIs so I don't think any change is needed but I thought I'd point it out in case you had any good ideas. Other drivers, such as postgresql, handle the unmodified URIs just fine.

Well, this was discussed. Not everything uses URIs, and not every URI is self-identifying (sqlite uses file:///), so that's a limitation unless we're willing to have drivers add their own non-standard URI formats.

@amoeba
Copy link
Member

amoeba commented Oct 15, 2025

Right, it just took me a sec to remember. I don't think any change is needed to the PR in its current form, then.

Comment on lines 211 to 214
- Only a URI, in which case the URI scheme will be assumed to be the
driver name and will be loaded as above. This will happen when
"://" is detected in the driver name. (It is not assumed that the
URI is actually a valid URI.)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe mention here that this only works if the driver natively supports URIs with a scheme that happens to be the same as the driver name (since the driver manager does not strip off the scheme before passing it to the driver).

Copy link
Member

@ianmcook ianmcook left a comment

Choose a reason for hiding this comment

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

Tested and works as described. Thanks! Just one minor comment to address a source of potential confusion for users.

@lidavidm lidavidm merged commit 7965684 into apache:main Oct 17, 2025
70 of 76 checks passed
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.

python/adbc_driver_manager: allow top-level URI, positional driver argument

3 participants