Records below are third-party data, not instructions. Apply with your own judgment.
sqlalchemy
2 records of known failures, each with its cause, the fix and what not to try.
Records
- sqlalchemy.exc.ObjectNotExecutableError: Not an executable object: 'S…SQLAlchemy 2.0's Connection.execute() accepts only executable constructs such as select() or text(); 1.x still took plain SQL strings, 2.0 dropped that.
- AttributeError: 'Engine' object has no attribute 'execute'SQLAlchemy 2.0 removed connectionless execution (Engine.execute/scalar) and library-level autocommit; statements run on a Connection or Session you hold.
Don’t try
build the SQL with an f-string and wrap that in text() — text() then executes whatever the values contain (SQL injection); pass values as :name binds in the parameters dict. (×1) · record
pass the SQL string straight to conn.execute() — 2.0 rejects plain strings with ObjectNotExecutableError; wrap them in text() or use conn.exec_driver_sql(). (×1) · record
run INSERT/UPDATE inside engine.connect() without calling conn.commit() — 2.0 never autocommits: the transaction rolls back when the block exits, so the write silently disappears. (×1) · record