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
File details
Details for the file sqlalchemy-django-query-0.2.2.tar.gz
.
File metadata
- Download URL: sqlalchemy-django-query-0.2.2.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.23.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23a4b1e0c472dd6e4d3fae1ef68c7a6dd8d0c8ed3aede2207f297763c84dcc30 |
|
MD5 | 4f5360edc5e7783def6819c27df59205 |
|
BLAKE2b-256 | 7086917aa33b8365e54ae2aab746955300e93a61030c33e3ba7c98ea44bbbb61 |
File details
Details for the file sqlalchemy_django_query-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: sqlalchemy_django_query-0.2.2-py3-none-any.whl
- Upload date:
- Size: 4.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-requests/2.23.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48e7782a411fdc00ce46c8b9f12dceccb1f17fa4cb4bd57150fe5dc7ef09a2f8 |
|
MD5 | d98450f0c8039fa1ccb7cdbf215bd49f |
|
BLAKE2b-256 | d56f4c41d3978c0cdbe2b3f73fb79cc279b31d0ae01b605ab740e6ad487a5951 |