-
Notifications
You must be signed in to change notification settings - Fork 608
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: API to get connection string from backend #10373
Comments
Why isn't having an existing connection enough? |
Because I am trying to use sqlalchemy to create the tables in the database, and as far as I can see there is no way to create a sqlalchemy engine from an existing connection, only from a connection string. |
There's definitely a way to do that: https://stackoverflow.com/a/23744051 |
Maybe is it that the DuckdbPyConnection doesn't implement the needed API? Am I passing in the wrong thing? # python -m pip install duckdb-engine>=0.13.4
# import duckdb_engine
import duckdb
import sqlalchemy as sa
from sqlalchemy.orm import declarative_base
_base = declarative_base()
class Pet(_base):
__tablename__ = "pets"
id = sa.Column(sa.Integer, primary_key=True)
name = sa.Column(sa.String)
age = sa.Column(sa.Integer)
species = sa.Column(sa.String)
con = duckdb.connect()
engine = sa.create_engine("duckdb://", creator=lambda: con)
_base.metadata.create_all(engine)
# AttributeError: 'duckdb.duckdb.DuckDBPyConnection' object has no attribute 'connection' Maybe this needs to happen at the duckdb-engine level? |
I don't know, but this certainly isn't an Ibis issue. |
Is your feature request related to a problem?
This may be out of scope for ibis, but I'm curious if you have any suggestions. See duckdb/duckdb#14549 (comment) for the motivation and use case. I went directly upstream, since I thought it would be useful to have that functionality in duckdb by itself.
If I understand correctly, sometimes ibis backends are constructed directly from a db connection, eg
ibis.duckdb.connect(duckdb.connect())
instead ofibis.duckdb.connect("db.duckdb")
. In that case, we would need to rely on the upstream backend to provide a.get_connection_string()
method. So maybe this is impossible to do for all backends.What is the motivation behind your request?
No response
Describe the solution you'd like
conn.connection_string
or similar.What version of ibis are you running?
NA
What backend(s) are you using, if any?
duckdb
Code of Conduct
The text was updated successfully, but these errors were encountered: