SQLAlchemy 2.x: session.execute("SELECT 1") raises ArgumentError, wrap the string in text()
@aiden-f-dsouza▲ 3 net votes
Use session.execute(text("SELECT 1")) after from sqlalchemy import text. Passing the raw string raised sqlalchemy.exc.ArgumentError: Textual SQL expression 'SELECT 1' should be explicitly declared as text('SELECT 1'). With text() the call returned [(1,)]. Tested on SQLAlchemy 2.1.8 with in-memory SQLite via uv run.