making SQLAlchemy great again
Project description
SQLAlchemy Lightening
===
Making SQLAlchemy great again
#### Install
```pip install sqlalchemy_ligthening```
#### Usage
```
# load by id
Person.get(1)
# load multiple by id
Person.get(1, 2, 3)
# or
Person.get([1, 2, 3])
# basic filter
Person.where(name='dpepper')
# where `name` in ...
Person.where(name=['dpepper', 'thatguy'])
# mix and match
Person.where(Person.id != 1, name='dpepper')
# standard utilities
Person.all
Person.first
# standard SQLAlchemy query
Person.query
```
## Example Setup
```
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy_lightening import LighteningBase
# create base sqlalchemy model
Base = declarative_base()
# extend LighteningBase mixin
class Person(LighteningBase, Base):
id = Column(Integer, primary_key=True)
name = Column(String(250))
engine = create_engine('sqlite:///:memory:')
session = sessionmaker(bind=engine)()
Base.metadata.create_all(engine)
Base.metadata.bind = engine
# wire things up
LighteningBase.query_class = session.query
# good to go
Person.winning
```
===
Making SQLAlchemy great again
#### Install
```pip install sqlalchemy_ligthening```
#### Usage
```
# load by id
Person.get(1)
# load multiple by id
Person.get(1, 2, 3)
# or
Person.get([1, 2, 3])
# basic filter
Person.where(name='dpepper')
# where `name` in ...
Person.where(name=['dpepper', 'thatguy'])
# mix and match
Person.where(Person.id != 1, name='dpepper')
# standard utilities
Person.all
Person.first
# standard SQLAlchemy query
Person.query
```
## Example Setup
```
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy_lightening import LighteningBase
# create base sqlalchemy model
Base = declarative_base()
# extend LighteningBase mixin
class Person(LighteningBase, Base):
id = Column(Integer, primary_key=True)
name = Column(String(250))
engine = create_engine('sqlite:///:memory:')
session = sessionmaker(bind=engine)()
Base.metadata.create_all(engine)
Base.metadata.bind = engine
# wire things up
LighteningBase.query_class = session.query
# good to go
Person.winning
```
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
Close
Hashes for sqlalchemy_lightening-0.2.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d4a510465b569729d5497403793ad59a568b8639394220204b266c71b0d6d62 |
|
MD5 | 1bddc689f9b990907f5265d451d65d7e |
|
BLAKE2b-256 | 33ba7803df2a6f437fa03d02151f434960a651a3dc9f87bcad7a34e28e45adae |