python - How to execute raw SQL in SQLAlchemy-flask app -
how execute raw sql in sqlalchemy?
i have python web app runs on flask , interfaces database through sqlalchemy.
i need way run raw sql. query involves multiple table joins along inline views.
i've tried:
connection = db.session.connection() connection.execute( <sql here> )
but keep getting gateway errors.
have tried:
result = db.engine.execute("<sql here>")
or:
from sqlalchemy import text sql = text('select name penguins') result = db.engine.execute(sql) names = [] row in result: names.append(row[0]) print names
Comments
Post a Comment