RazerM / sqlalchemy_aio

Asyncio strategy for SQLAlchemy.
Other
300 stars 17 forks source link

Extend the AsyncEngine from the correct class #23

Closed farvour closed 4 years ago

farvour commented 5 years ago

This issue cropped up when trying to use the prometheus-query-exporter.

It would seem that the Identified class from the core SQLAlchemy does not really contain all of the pieces to be an engine. This resulted in errors like

2019-10-17 20:53:36,303 - ERROR - query-exporter - error from database "snowflake": 'AsyncioEngine' object has no attribute '_connection_cls'.
2019-10-17 20:53:36,304 - DEBUG - query-exporter - updating metric "database_errors" inc 1 {database="snowflake"}

When using other dialects/drivers that do not natively support asyncio (hence this wrapper is invoked?).

This patch seems to fix that issue and now my connections and queries are working as expected.

2019-10-18 03:54:19,568 - DEBUG - query-exporter - updating metric "data_snowflake_foo_util__table_health_stats_latest" set 1.000000 {database="snowflake",schema_name="fooschema",table_name="footable"}
2019-10-18 03:54:19,570 - DEBUG - query-exporter - updating metric "queries" inc 1 {database="snowflake",status="success"}
RazerM commented 4 years ago

It is intentional that AsyncEngine doesn't inherit from engine. To use the underlying engine asynchronously, the .sync_engine attribute should be used. I assume this is a prometheus-query-exporter bug.