Skip to main content

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

installs

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

sqlalchemy_lightening-0.6.0.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

sqlalchemy_lightening-0.6.0-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file sqlalchemy_lightening-0.6.0.tar.gz.

File metadata

  • Download URL: sqlalchemy_lightening-0.6.0.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.14

File hashes

Hashes for sqlalchemy_lightening-0.6.0.tar.gz
Algorithm Hash digest
SHA256 69f3993343e0b05bce07554b220d6753e14da7c52710084ca1f48e5cf4f2652b
MD5 eb86670bd4ceb20bb226816670be0550
BLAKE2b-256 46fd9cc2d5772c22aa42df68dbb1ec87998b0575020e5b517f12069a575c7915

See more details on using hashes here.

File details

Details for the file sqlalchemy_lightening-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: sqlalchemy_lightening-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.14

File hashes

Hashes for sqlalchemy_lightening-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e380c30f6690d84bec22b3d70273736b5a5e28e767b08be66e9a251387696f39
MD5 666fbead66a6734dec6ccd91782fb0b1
BLAKE2b-256 a1c32931f9adaf81383fbfc5be417528b8107459445e46c787969a6b4b663aff

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page