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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 050108e8cf7727ed1590b2dd2f1d33cff546a04361a64c93d73baaadda823b08 |
|
MD5 | 15ef65e170f28d70661c2177468e4cdd |
|
BLAKE2b-256 | badacfc18288802c1cc3eada711db73aac885fe78cb96612175db407d1f85a6b |
Close
Hashes for sqlalchemy_django_query-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa713bd4f442bb476742777b83292587639f9c3d842f4c6f0aec847d4aca6e09 |
|
MD5 | 6d0e48f25f29344234a6e37e0f43ac5f |
|
BLAKE2b-256 | fd15909da249208c8751050b1a805af439d4a6ae5d76d6f3063bfb313387ee56 |