UNKNOWN
Project description
rebecca.repository
An implementation of repository pattern for SQLAlchemy.
Getting Started
install by pip:
$ pip install rebecca.repository
Implement your model by SQLAlchemy:
from sqlalchemy import Column, Integer, Unicode from sqlalchemy.ext.declarative import declarative_base Base = declarative_base() DBSession = scoped_session(sessionmaker()) class Person(Base): __tablename__ = "person" id = Column(Integer, primary_key=True) name = Column(Unicode(255)) age = Column(Integer, default=0)
Get repository:
from rebecca.repository.sqla import SQLARepository person_repository = SQALRepository(Person, Person.id, DBSession())
this repository for Person model. To get person, use Person.id as key.
basic dict interface
create object for demonstration:
person1 = Person(name=u"person1") DBSession.add(person1) DBSession.flush() # to generate person.id
A repository has dict like interface:
person_repository[person.id] person_repository.get(person.id)
conditional repository
repository can configure to set condition:
person_repository = SQALRepository(Person, Person.id, DBSession(), condition=Person.age>30)
Contributors
Atsushi Odagiri, Original Author
Changelog
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
rebecca.repository-0.1.zip
(7.0 kB
view details)
File details
Details for the file rebecca.repository-0.1.zip
.
File metadata
- Download URL: rebecca.repository-0.1.zip
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a22a2c57ac35e29a688af25dfaf2006393a92006bb33706ea2a7bca2d02c8cd |
|
MD5 | f57dd0dbe03c661b6bff8a5e0b8eadde |
|
BLAKE2b-256 | c6868f5d545ae7f2f9b5737283d6b45f70ba3f4ea60011f17440e8a98dd5fbb2 |