A module that implements a more Django like interface for SQLAlchemy
Project description
sqlalchemy-django-query
A module that implements a more Django like interface for SQLAlchemy (currently < 1.4) query objects. It's still API compatible with the regular one but extends it with Djangoisms.
Example
class Base(object):
@declared_attr
def __tablename__(cls):
return cls.__name__.lower()
id = Column(Integer, primary_key=True)
Base = declarative_base(cls=Base)
class Blog(Base):
name = Column(String)
entries = relationship('Entry', backref='blog')
class Entry(Base):
blog_id = Column(Integer, ForeignKey('blog.id'))
pub_date = Column(Date)
headline = Column(String)
body = Column(String)
engine = create_engine('sqlite://')
Base.metadata.create_all(engine)
# session with our class
session = Session(engine, query_cls=DjangoQuery)
session.query(Blog).filter_by(name__exact='blog1').one()
session.query(Blog).filter_by(name__contains='blog').all()
session.query(Entry).filter_by(pub_date__year=2011).one()
session.query(Blog).filter_by(entries__headline__exact='b2 headline 2').one()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for sqlalchemy-django-query-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0519694f4185a36710d4a0bec769769ec8e74f820e0547bf67e54f64421c208d |
|
MD5 | 67faebacf6e1dbeb94c95b9a63e38412 |
|
BLAKE2b-256 | d8cc9b18bbf8ba1c6c9482eb097637078ce5b16560a53b7deb1c4a757ebc2685 |
Close
Hashes for sqlalchemy_django_query-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 021afa7d85085c15101e13f2ebccc95f7c118c2df91784a05e4b8f5a13714feb |
|
MD5 | 7540f4856cd1ca8d07e2f2ab17062c1b |
|
BLAKE2b-256 | ce8c9f72dcf35db67b1b39ff054974da244c826c6a2f9549903ed50a69a6268a |