美文网首页
How to build a flask application

How to build a flask application

作者: 樊海鹏 | 来源:发表于2017-08-02 18:43 被阅读0次
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base

engine = create_engine('sqlite:///webmgmt.db', convert_unicode=True, echo=False)
Base = declarative_base()
Base.metadata.reflect(engine)


from sqlalchemy.orm import relationship, backref

class Users(Base):
    __table__ = Base.metadata.tables['users']


if __name__ == '__main__':
    from sqlalchemy.orm import scoped_session, sessionmaker, Query
    db_session = scoped_session(sessionmaker(bind=engine))
    for item in db_session.query(Users.id, Users.name):
        print item

相关文章

网友评论

      本文标题:How to build a flask application

      本文链接:https://www.haomeiwen.com/subject/lvuylxtx.html