Code Monkey home page Code Monkey logo

Comments (7)

simonw avatar simonw commented on June 10, 2024

I'm seeing this error too: https://github.com/simonw/simonwillisonblog-backup/actions/runs/4108524950/jobs/7089316644

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1410, in execute
    meth = statement._execute_on_connection
AttributeError: 'str' object has no attribute '_execute_on_connection'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.10.9/x64/bin/db-to-sqlite", line 8, in <module>
    sys.exit(cli())
  File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/db_to_sqlite/cli.py", line 112, in cli
    results = db_conn.execute("select * from {}".format(table_quoted))
  File "/opt/hostedtoolcache/Python/3.10.9/x64/lib/python3.10/site-packages/sqlalchemy/engine/base.py", line 1412, in execute
    raise exc.ObjectNotExecutableError(statement) from err
sqlalchemy.exc.ObjectNotExecutableError: Not an executable object: 'select * from "auth_permission"'

from db-to-sqlite.

simonw avatar simonw commented on June 10, 2024

I bet this is related to SQLAlchemy 2: https://docs.sqlalchemy.org/en/14/changelog/migration_20.html

% pip freeze | grep SQ 
SQLAlchemy==2.0.1

from db-to-sqlite.

simonw avatar simonw commented on June 10, 2024

Running this fixes the errors:

pip install 'SQLAlchemy<2.0' 

from db-to-sqlite.

simonw avatar simonw commented on June 10, 2024

With SQLAlchemy 1.4 installed I can run this to see migration hints:

SQLALCHEMY_WARN_20=1 pytest

I get back 41 warnings:

tests/test_db_to_sqlite.py: 41 warnings
tests/test_redact.py: 12 warnings
  /Users/simon/Dropbox/Development/db-to-sqlite/db_to_sqlite/cli.py:112: 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)
    results = db_conn.execute("select * from {}".format(table_quoted))

tests/test_db_to_sqlite.py: 43 warnings
tests/test_redact.py: 12 warnings
  /Users/simon/Dropbox/Development/db-to-sqlite/db_to_sqlite/cli.py:186: RemovedIn20Warning: The Row.keys() method is considered legacy as of the 1.x series of SQLAlchemy and will be removed in 2.0. Use the namedtuple standard accessor Row._fields, or for full mapping behavior use  row._mapping.keys()  (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
    d = dict(row)

tests/test_db_to_sqlite.py: 134 warnings
tests/test_redact.py: 36 warnings
  /Users/simon/Dropbox/Development/db-to-sqlite/db_to_sqlite/cli.py:114: RemovedIn20Warning: Using non-integer/slice indices on Row is deprecated and will be removed in version 2.0; please use row._mapping[<key>], or the mappings() accessor on the Result object. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
    rows = (redacted_dict(r, redact_these) for r in results)

tests/test_db_to_sqlite.py::test_specific_tables[postgresql://localhost/test_db_to_sqlite]
tests/test_db_to_sqlite.py::test_specific_tables[postgresql://localhost/test_db_to_sqlite]
tests/test_db_to_sqlite.py::test_specific_tables[postgres://localhost/test_db_to_sqlite]
tests/test_db_to_sqlite.py::test_specific_tables[postgres://localhost/test_db_to_sqlite]
  /Users/simon/Dropbox/Development/db-to-sqlite/db_to_sqlite/cli.py:109: 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)
    count = db_conn.execute(

tests/test_db_to_sqlite.py::test_sql_query[postgresql://localhost/test_db_to_sqlite]
tests/test_db_to_sqlite.py::test_sql_query[postgres://localhost/test_db_to_sqlite]
  /Users/simon/Dropbox/Development/db-to-sqlite/db_to_sqlite/cli.py:170: 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)
    results = db_conn.execute(sql)

tests/test_db_to_sqlite.py::test_sql_query[postgresql://localhost/test_db_to_sqlite]
tests/test_db_to_sqlite.py::test_sql_query[postgresql://localhost/test_db_to_sqlite]
tests/test_db_to_sqlite.py::test_sql_query[postgres://localhost/test_db_to_sqlite]
tests/test_db_to_sqlite.py::test_sql_query[postgres://localhost/test_db_to_sqlite]
  /Users/simon/Dropbox/Development/db-to-sqlite/db_to_sqlite/cli.py:171: RemovedIn20Warning: The Row.keys() method is considered legacy as of the 1.x series of SQLAlchemy and will be removed in 2.0. Use the namedtuple standard accessor Row._fields, or for full mapping behavior use  row._mapping.keys()  (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
    rows = (dict(r) for r in results)

tests/test_db_to_sqlite.py::test_sql_query[postgresql://localhost/test_db_to_sqlite]
tests/test_db_to_sqlite.py::test_sql_query[postgresql://localhost/test_db_to_sqlite]
tests/test_db_to_sqlite.py::test_sql_query[postgresql://localhost/test_db_to_sqlite]
tests/test_db_to_sqlite.py::test_sql_query[postgresql://localhost/test_db_to_sqlite]
tests/test_db_to_sqlite.py::test_sql_query[postgres://localhost/test_db_to_sqlite]
tests/test_db_to_sqlite.py::test_sql_query[postgres://localhost/test_db_to_sqlite]
tests/test_db_to_sqlite.py::test_sql_query[postgres://localhost/test_db_to_sqlite]
tests/test_db_to_sqlite.py::test_sql_query[postgres://localhost/test_db_to_sqlite]
  /Users/simon/.local/share/virtualenvs/db-to-sqlite-Nk_u3PUs/lib/python3.10/site-packages/sqlite_utils/db.py:3604: RemovedIn20Warning: Using non-integer/slice indices on Row is deprecated and will be removed in version 2.0; please use row._mapping[<key>], or the mappings() accessor on the Result object. (Background on SQLAlchemy 2.0 at: https://sqlalche.me/e/b8d9)
    for record in records:

from db-to-sqlite.

simonw avatar simonw commented on June 10, 2024

Doing this fixes the warnings about .execute():

from sqlalchemy import text

# ...

results = db_conn.execute(text(sql))

from db-to-sqlite.

simonw avatar simonw commented on June 10, 2024

Finally got the tests to pass in:

from db-to-sqlite.

jesus-hergueta avatar jesus-hergueta commented on June 10, 2024

Thank you @simonw !

from db-to-sqlite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.