0

I'm new to sqlalchemy, I have a flask app and I want to use flask-sqlalchemy with sqlite for flask-admin in it. I wanted to know if I could use pure sql commands while I'm using sqlalchemy or not.

1

1 Answer 1

1

Yes you can, for example:

import sqlalchemy
from sqlalchemy.orm import sessionmaker, scoped_session

engine = sqlalchemy.create_engine('sqlite:///foo.db')
Session = scoped_session(sessionmaker(bind=engine))
session = Session()

sql = text('SELECT id FROM users')
result = session.execute(sql)
ids = [row[0] for row in result]
print(ids)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.