crate / crate/sqlalchemy-cratedb
how to properly create a pool connection using SqlAlchemy?
- Dominant language
- Python
- Stars
- 9
- Forks
- 4
- Avg merge
- 6d 12h
- Merged PRs (30d)
- 3
Description
we are trying to set up a dbpool connection for crate using SqlAlchemy (1.3.4), but we get the following error:
```
Traceback (most recent call last):
File "/Users/facca/.local/share/virtualenvs/ngsi-timeseries-api-x5Z2-yqd/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 697, in _finalize_fairy
fairy._reset(pool)
File "/Users/facca/.local/share/virtualenvs/ngsi-timeseries-api-x5Z2-yqd/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 893, in _reset
pool._dialect.do_rollback(self)
TypeError: do_rollback() missing 1 required positional argument: 'connection'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/facca/.local/share/virtualenvs/ngsi-timeseries-api-x5Z2-yqd/lib/python3.8/site-packages/sqlalchemy/pool/base.py", line 270, in _close_connection
self._dialect.do_close(connection)
TypeError: do_close() missing 1 required positional argument: 'dbapi_connection'
```
this how we create the connection:
```
...
from crate.client.sqlalchemy.dialect import CrateDialect
...
def get_connection(self):
url = "{}:{}".format(self.host, self.port)
connection = client.connect([url], error_trace=True)
return connection
...
dbpool = pool.QueuePool(self.get_connection, max_overflow=10, pool_size=5, pre_ping=False, dialect=CrateDialect)
self.connection = dbpool.connect()
...
self.connection.close()
```
the error bombs on closing the connection
Contributor guide
Assessment
This issue has not been assessed yet.