I can't seem to get SQLAlchemy to generate proper SQL that satisfies SQLite.
SQLAlchmey query:
q = select([0]).union_all(select([0]).limit(30))
That produces the following SQL:
SELECT ? UNION ALL (SELECT 0 LIMIT ? OFFSET ?)
Which leads to:
sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) near "(": syntax error
The issues seems to be the () that SQLAlchemy adds after the UNION ALL clause.
Without the parentheses the query executes fine.
ie. the following SQL works without issue:
SELECT 0 UNION ALL SELECT 0 LIMIT 30 OFFSET 0
Note:
SQLAlchemy does not generate parentheses if no
LIMITclause is provided.I am using:
- Python 3.8
- SQLAlchemy v1.3.19
- SQLite v3.31.1