A simple SELECT statement in an existing table with SQLAlchemy

Nowhere on the Internet is there a simple guide to a few lines in a simple SELECT for SQLAlchemy 1.0.

Assuming I established a database connection using create_engine() and my database tables already exist, I would like to know how to execute the following query:

 select name, age from users where name = 'joe' and age = 100 
+6
source share
1 answer

I think the following will work to query the user database table

 from sqlalchemy.sql import and_ s = select([users]).where(and_(users.c.name == 'joe', users.c.age == 100)) for row in conn.execute(s): print row 

http://docs.sqlalchemy.org/en/latest/core/tutorial.html

-2
source

Source: https://habr.com/ru/post/988937/


All Articles