为sqlalchemy提供简洁的pythonic查询语法
pythonic-sqlalchemy-quer的Python项目详细描述
pythonic_sqlalchemy_query module为sqlalchemy提供了简洁的pythonic查询语法。例如,这两个查询产生相同的结果:
pythonic_query=session.User['jack'].addresses['jack@google.com']traditional_query=(# Ask for the Address...session.query(Address).# by querying a User named 'jack'...select_from(User).filter(User.name=='jack').# then joining this to the Address 'jack@google.com`.join(Address).filter(Address.email_address=='jack@google.com')
安装
pip install pythonic_sqlalchemy_query
与sqlalchemy一起使用
在大多数情况下:
frompythonic_sqlalchemy_queryimportQueryMakerSession# Construct an engine as usual.engine=create_engine(...)# Create a session aware of this module.Session=sessionmaker(bind=engine,class_=QueryMakerSession)session=Session()# After defining some declarative classes, query away:forresultinsession.User['jack'].addresses:# Do some processing on result...
examples提供完整的工作代码。
与烧瓶sqlalchemy一起使用
在大多数情况下:
frompythonic_sqlalchemy_query.flaskimportSQLAlchemyPythonicQueryapp=Flask(__name__)db=SQLAlchemyPythonicQuery(app)# After defining some declarative classes, query away:forresultinUser['jack'].addresses:# Do some processing on result...
examples提供完整的工作代码。
许可证
这个软件是根据MIT license条款发布的。