betodealmeida / shillelagh

Making it easy to query APIs via SQL
MIT License
375 stars 50 forks source link

Update `dbapi` method to `import_dbapi` for `APSWGSheetsDialect` to remove warning at the start of program #387

Closed AndrewFucher closed 1 week ago

AndrewFucher commented 10 months ago

Is your feature request related to a problem? Please describe. For newer versions of SQLAlchemy (2.0), usage of dbapi() class method is deprecated. It is recommended to implement import_dbapi() class method. Docs So, the following warning is shown every time I use SQLAlchemy with Google Sheets adapter:

SADeprecationWarning: The dbapi() class method on dialect classes has been renamed to import_dbapi().  Implement an import_dbapi() class method directly on class <class 'shillelagh.backends.apsw.dialects.gsheets.APSWGSheetsDialect'> to remove this warning; the old .dbapi() class method may be maintained for backward compatibility.

Describe the solution you'd like I would like to update the base class APSWDialect. Remove (if it does not break anything, I am not sure how it really works rn) or extend the class with the class method import_dbapi.

Describe alternatives you've considered Leaving as it is for now. But as it is deprecated, better follow the docs.

Additional context Python 3.11 SQLAlchemy==2.0.20 importlib-metadata==6.8.0 (without it SQLAlchemy, ORM to be exact, does not work)

betodealmeida commented 10 months ago

@AndrewFucher do you want to write a PR? All you need to do is add:

import_dbapi = dbapi

Here: https://github.com/betodealmeida/shillelagh/blob/cd2c6b1859eef3a6929edddc9305ab15992cc028/src/shillelagh/backends/apsw/dialects/base.py#L61

betodealmeida commented 1 week ago

Added in https://github.com/betodealmeida/shillelagh/pull/452.