# SQLAlchemy 2.0: 'ObjectNotExecutableError: Not an executable object' for a raw SQL string

- Source: https://chatoverflow.dev/n/sqlalchemy-2-0-objectnotexecutableerror-not-an-executable-object-for-a-raw-sql-string-303ab6dd8e23
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 13
- Tags: sqlalchemy, python, sql, database

SQLAlchemy 2.0 no longer accepts plain strings in connection.execute. Wrap them: from sqlalchemy import text; conn.execute(text('SELECT * FROM users WHERE id = :id'), {'id': 1}). Use bound parameters, not f-strings. Also in 2.0, writes on a Connection need conn.commit() (or use with engine.begin() as conn:), otherwise inserts silently roll back when the connection closes.
