crate / crate/sqlalchemy-cratedb

TypeError: Connection.__init__() got an unexpected keyword argument 'database'

Open
#222 0 comments 0 reactions 0 assignees View on GitHub
pgcompat
Dominant language
Python
Stars
9
Forks
4
Avg merge
6d 12h
Merged PRs (30d)
3

Description

## Problem

Already mentioned in GH-73, when trying to load data with [dlt](https://github.com/dlt-hub/dlt) using `destination=dlt.destinations.sqlalchemy("crate://crate@localhost:4200")`, this exception is raised:

```
Traceback (most recent call last):
File "/path/to/dlt/pipeline/pipeline.py", line 771, in _sync_destination
remote_state = self._restore_state_from_destination()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/dlt/pipeline/pipeline.py", line 1531, in _restore_state_from_destination
with self._get_destination_clients(schema)[0] as job_client:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
File "/path/to/dlt/destinations/job_client_impl.py", line 433, in __enter__
self.sql_client.open_connection()
File "/path/to/dlt/destinations/impl/sqlalchemy/db_api_client.py", line 139, in open_connection
self._current_connection = self.credentials.borrow_conn()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/dlt/destinations/impl/sqlalchemy/configuration.py", line 53, in borrow_conn
return engine_.connect()
^^^^^^^^^^^^^^^^^
[...]
File "/path/to/sqlalchemy/engine/create.py", line 646, in connect
return dialect.connect(*cargs, **cparams)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/path/to/sqlalchemy_cratedb/dialect.py", line 261, in connect
return self.dbapi.connect(servers=servers, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: Connection.__init__() got an unexpected keyword argument 'database'
```

## Thoughts
We are aware CrateDB does not support `CREATE DATABASE` and friends, but maybe the SQLAlchemy dialect could be made more compliant?

Contributor guide

Open the contributing guide

Research direction

Start in sqlalchemy_cratedb/dialect.py around connect (line 261) and reproduce the dlt SQLAlchemy URL case shown in the traceback. Check how the database keyword reaches the CrateDB driver and compare the existing GH-73 context; done means the connection no longer raises this TypeError while preserving supported connection behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sqlalchemy
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.