Is there a way to build a Query
object in SQLAlchemy which will be the equivalent of:
SELECT * FROM (VALUES (1, 2, 3)) AS sq;
From what I see in the documentation, the VALUES
clause appears only in use with INSERT
.
This is now natively available in SQLAlchemy.
Your example would be written as:
from sqlalchemy import select, column, Integer
from sqlalchemy.sql import Values
select(Values(column('Number', Integer), name='sq').data([(1,), (2,), (3,)]))
There doesn't seem to be any documentation on this, but you can have a look at the test cases https://github.com/sqlalchemy/sqlalchemy/blob/master/test/sql/test_values.py
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With