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])
# 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.5.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58b01750aacb56186d7d4645131796812811cff2b7f8496c74e9cee0ffe165f3 |
|
MD5 | c91b1959536e5982d3222d43982d6757 |
|
BLAKE2b-256 | ab915e439e2efb1634504fa4ac7923a5e08e1012347e955fab1bfb0088b371e1 |
Close
Hashes for sqlalchemy_lightening-0.5.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c66468d465e5f09e2e40e66a0964a37db7c91f33835b4e23af8c2ed9c806acea |
|
MD5 | 99148f60afb539a4f572d6715f11530a |
|
BLAKE2b-256 | 849b51e5f7733fa7c16686f312c06a21c9b5d46897c07cb4bf29de33ed0ede7d |