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)
# 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

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.4.1.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqlalchemy_lightening-0.4.1.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for sqlalchemy_lightening-0.4.1.tar.gz
Algorithm Hash digest
SHA256 d96c71ca631af0bb06e5d32514809ae547c86d6ee27f72976352b1c684450bcc
MD5 219d1bff315b6ba9cd6248ba5b70cd0f
BLAKE2b-256 499047118d2eb748e1b1ce10e8d1230e3a61077f541b51ab5632e8837b5922d6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sqlalchemy_lightening-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.7.3

File hashes

Hashes for sqlalchemy_lightening-0.4.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e605d6219a9a99e1f648a9d4fa3644bb3f831eed0aa318d3a62c77f1e03f43d3
MD5 124da7f9258a167b2a35add3696f8e0b
BLAKE2b-256 ffccfae9ee60d963b0dbf9129ca4d557a83259f846d90dc03fb953179e69516a

See more details on using hashes here.

Supported by

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