关于select语句的SQLAlchemy教程

关于select语句的SQLAlchemy教程,sqlalchemy,Sqlalchemy,我正试图从下面的网站上学习sqlalchemy教程 http://www.rmunn.com/sqlalchemy-tutorial/tutorial.html 在做select语句时,我真的被卡住了 根据教程,选择如下所示,但我不理解他在users.select中使用users.c.name=='John'的部分。语句中的users.c是什么 users.name就足够了吗 from sqlalchemy import * # Let's re-use the same database

我正试图从下面的网站上学习sqlalchemy教程

http://www.rmunn.com/sqlalchemy-tutorial/tutorial.html
在做select语句时,我真的被卡住了

根据教程,选择如下所示,但我不理解他在users.select中使用users.c.name=='John'的部分。语句中的users.c是什么

users.name就足够了吗

from sqlalchemy import *

# Let's re-use the same database as before
db = create_engine('sqlite:///tutorial.db')

db.echo = True  # We want to see the SQL we're creating

metadata = BoundMetaData(db)

# The users table already exists, so no need to redefine it. Just
# load it from the database using the "autoload" feature.
users = Table('users', metadata, autoload=True)

def run(stmt):
    rs = stmt.execute()
    for row in rs:
        print row

# Most WHERE clauses can be constructed via normal comparisons
s = users.select(users.c.name == 'John')
run(s)
s = users.select(users.c.age < 40)
run(s)
回答问题的c部分:

users是表示数据库中的表的实例 c是一个,只是to的别名,所以这就是访问表列的方式

至于教程:

您提供的链接引用了sqlalchemy版本0.2。不用说,它很古老。请考虑官方和具体的案件,