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.3.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4b12d26022801df9d09e4b38909a8ff9bbc4516de8d15fe34f3674fe67b89a5 |
|
MD5 | 400c55c0201995ba3465d66448f221d8 |
|
BLAKE2b-256 | bf1681bc162362cbd4b09242a993e9c5c7763361536ed0a1d6ca6e45d8ba8a02 |
Close
Hashes for sqlalchemy_lightening-0.3.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f83a9aed1bb3025dfb4959585d6b270b07414940507fd1c8330a673e4b43a203 |
|
MD5 | 243bb9e56803a35bac9ab20e0225af31 |
|
BLAKE2b-256 | c67e827b870d9b8f5249b686075e9d59aa0bca24bd205ecc2a18ca29b5ab7dc9 |