Skip to main content

sqlalchemy_bundle_model

An extension to SQLAlchemy to treat aggregated columns and clauses as Models

installation

$ pip install sqlalchemy-bundle-model

usage

>>> from sqlalchemy import Column, BigInteger, Text, ForeignKey
>>> from sqlalchemy.orm import declarative_base, relationship, sessionmaker
>>> from sqlalchemy.engine import create_engine
>>> from sqlalchemy_bundle_model import BundleModel, col
>>> DeclarativeBase = declarative_base()
>>> class User(DeclarativeBase):
...     __tablename__ = "users"
...     id = Column(BigInteger, primary_key=True)
...     name = Column(Text, nullable=False)
...     group_id = Column(ForeignKey("groups.id"), nullable=False)
...
...     group = relationship("Group")
...
>>> class Group(DeclarativeBase):
...     __tablename__ = "groups"
...     id = Column(BigInteger, primary_key=True)
...     name = Column(Text, nullable=False)
...
>>> class GroupUser(BundleModel):
...     id = col(int, User.id)
...     name = col(str, User.name)
...     group_name = col(str, Group.name)
...
...     @staticmethod
...     def join(_query):
...         return _query.join(User.group)
...
>>> engine = create_engine("sqlite://")
>>> DeclarativeBase.metadata.create_all(bind=engine)
>>> session_cls = sessionmaker(bind=engine)
>>> session = session_cls()
>>> user = User(id=1, name="John Doe")
>>> group = Group(id=1, name="A")
>>> user.group = group
>>> session.add(user)
>>> session.commit()
>>> query = session.query(GroupUser)
>>> query = GroupUser.join(query)
>>> result = query.first()
>>> result.group_name == "A"

Metadata

Release files for sqlalchemy-bundle-model 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlalchemy-bundle-model 0.2.1
File Size Uploaded Provenance Actions
sqlalchemy_bundle_model-0.2.1.tar.gz 7.7 kB Without provenance Details for sqlalchemy_bundle_model-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sqlalchemy-bundle-model 0.2.1
File Interpreter ABI Platform Actions
sqlalchemy_bundle_model-0.2.1-py3-none-any.whl Python 3 none any Details for sqlalchemy_bundle_model-0.2.1-py3-none-any.whl

Total release size: 16.1 kB

Release files / sqlalchemy_bundle_model-0.2.1.tar.gz

Download URL sqlalchemy_bundle_model-0.2.1.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b7388ac8939dfc0850d1aa886894accd283bec6028e60a08e753122733688158
BLAKE2b-256 checksum
How to use checksums
95dc99b39d5ef9bf4bb36f2a7abfcde722133ec32f0b89d12a577983392f8280
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.9.1 Darwin/20.3.0

Release files / sqlalchemy_bundle_model-0.2.1-py3-none-any.whl

Download URL sqlalchemy_bundle_model-0.2.1-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bac69090456cb00c20342aebda71a6910320bc06c5108da520c582fc57ba8a91
BLAKE2b-256 checksum
How to use checksums
778ab42f2b8315c68d87ad0236eb494133d2a43ebfd080e82d050dcd812be4cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.4 CPython/3.9.1 Darwin/20.3.0

Security for sqlalchemy-bundle-model 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page