SQLAlchemy参考

  1. 云栖社区>
  2. 博客>
  3. 正文

SQLAlchemy参考

zephyr 2016-06-03 18:22:43 浏览2249
展开阅读全文

1. 基本流程

# -*- coding: utf-8 -*-fromsqlalchemyimport create_engine
fromsqlalchemy.ormimport sessionmaker
fromsqlalchemyimport Column
fromsqlalchemy.typesimport String, Integer
fromsqlalchemy.ext.declarativeimport declarative_base

engine = create_engine('postgresql://test@localhost:5432/test')
DBSession = sessionmaker(engine)
session = DBSession()

BaseModel = declarati

网友评论

登录后评论
0/500
评论
zephyr
+ 关注