Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

critical bug - csvsql "ObjectNotExecutableError" due to SQLAlchemy 2.0 deprecations now unsupported #1212

Closed
maaaaz opened this issue Oct 2, 2023 · 5 comments

Comments

@maaaaz
Copy link

maaaaz commented Oct 2, 2023

Hello there,

Here is a critical bug due the SQLAlchemy depreciated features:

  1. cd /tmp/ && wget https://github.com/wireservice/csvkit/raw/master/examples/foo1.csv

  2. csvsql with SQLAlchemy < 2.0: some warnings, but execution is OK

$ SQLALCHEMY_WARN_20=1 csvsql -u 1 foo1.csv --tables db --query 'SELECT * FROM db'

/usr/local/lib/python3.11/dist-packages/csvkit/utilities/csvsql.py:236: RemovedIn20Warning: Passing a string to Connection.execute() is deprecated and will be removed in version 2.0.  Use the text() construct, or the Connection.exec_driver_sql() method to invoke a driver-level SQL string. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
id,name,age
1.0,Jake,22.0
2.0,Howard,21.0
  1. csvsql with SQLAlchemy >= 2.0: crash with "ObjectNotExecutableError"
$ csvsql -u 1 foo1.csv --tables db --query 'SELECT * FROM db'
/tmp/lol/foo2/lib/python3.11/site-packages/pkg_resources/__init__.py:121: DeprecationWarning: pkg_resources is deprecated as an API
ObjectNotExecutableError: Not an executable object: 'SELECT * FROM db'

The root cause to fix seems to wrap the following SQL string parameter "query", such as documented in the warning, and also here with sqlalchemy text

rows = self.connection.execute(query)

pandas-dev/pandas#51061
sqlalchemy/sqlalchemy#9155

@maaaaz maaaaz changed the title csvsql "ObjectNotExecutableError" critical bug due to SQLAlchemy 2.0 csvsql "ObjectNotExecutableError" critical bug due to SQLAlchemy 2.0 deprecations now unsupported Oct 2, 2023
@maaaaz
Copy link
Author

maaaaz commented Oct 2, 2023

By the way, before csvkit fixes this issue, the current ugly workaround is to do a pip install sqlalchemy==1.4.49 after pip install csvkit, to force an old version of sqlalchemy to be used.

@maaaaz maaaaz changed the title csvsql "ObjectNotExecutableError" critical bug due to SQLAlchemy 2.0 deprecations now unsupported critical bug - csvsql "ObjectNotExecutableError" due to SQLAlchemy 2.0 deprecations now unsupported Oct 2, 2023
@jpmckinney
Copy link
Member

Thank you for reporting!

@maaaaz
Copy link
Author

maaaaz commented Oct 4, 2023

Thanks, when did you plan to update the package on pypi ?

@jpmckinney
Copy link
Member

Up: https://pypi.org/project/csvkit/

@maaaaz
Copy link
Author

maaaaz commented Oct 4, 2023

Great, I will try !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants