this is my query:
select 'somestring' as my_col_name
from my_table
when using sql alchemy:
query = db.session.query(
'somestring'.label('my_col_name'))
)
but I get this error:
'str' object has no attribute 'label'
how can I add a label on sqlalchemy to a static string field? (I need it for some unions I do after)
use literal_column
query = db.session.query(
literal_column("'somestring'").label('my_col_name'))
)
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