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 import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
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
Built Distribution
Close
Hashes for sqlalchemy_lightening-0.4.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49d44d35d2289f9142cd82964257d4681e72a865b03a687bd9f84905f91b7832 |
|
MD5 | fc1c064fff5239a409e6d941746564ff |
|
BLAKE2b-256 | 06de89926a11a2eb185649827a57c273bb19a933a0f4c38423c24d07347a2039 |
Close
Hashes for sqlalchemy_lightening-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a346141cc41b1422faf0a9a54355637f17b181fc759ef05456c13b8f5377eeff |
|
MD5 | 40400980387149c67534b29afbdb749e |
|
BLAKE2b-256 | 3e9562dca62f9a7c5ebd4a4bdef1f572d1b021180b3bc882e4dae1ea318454ac |