Open NickCrews opened 1 month ago
I can't say I'd really recommend this, but you can do this to work around that error:
from duckdb_engine import ConnectionWrapper
engine = sa.create_engine("duckdb://", creator=lambda: ConnectionWrapper(con))
this class just patches the duckdb connection to be what sqlalchemy expects from postgres/psycopg2
Thanks!
I can't say I'd really recommend this,
because you'd like to keep ConnectionWrapper
as non-public, and you might make breaking changes at any time? That seems like a good idea.
What would you think about if you encapsulated that into a more simple API, and then exposed that publicly:
def create_engine(con: duckdb.DuckDBPyConnection) -> sqlalchemy.engine.Engine:
return sa.create_engine("duckdb://", creator=lambda: ConnectionWrapper(con))
I'm not that familiar with sqlalchemy's API though, are users then gonna want to pass in various kwargs into creat_engine?
What happened?
See https://github.com/duckdb/duckdb/discussions/14549#discussion-7364961. Any way to go from
duckdb.DuckDBPyConnection
to asqlalchemy.engine
? I have to make my own little wrapper class that provides the needed methods for sqlalchemy? Thanks!DuckDB Engine Version
NA
DuckDB Version
NA
SQLAlchemy Version
No response
Relevant log output
No response
Code of Conduct