Skip to main content

CRUD operations for SQLAlchemy models

Project description

CRUDAL

Ready to use CRUD methods for SQLAlchemy models. Both Sync and Async

pip install crudal

Examples

from sqlalchemy import Integer, String, create_engine
from sqlalchemy.orm import Mapped, Session, mapped_column

from crudal import DeclarativeCrudBase

engine = create_engine("sqlite://")

class User(DeclarativeCrudBase):
    __tablename__ = "person"

    id: Mapped[int] = mapped_column(Integer, primary_key=True)
    name: Mapped[str] = mapped_column(String, nullable=False)

DeclarativeCrudBase.metadata.create_all(bind=engine)

Find

with Session(bind=engine) as session:
    p = User(name="Andrew")
    p.add(session=session)

    p2 = User(name="Bob")
    p2.add(session=session)

    # find person with name "Andrew"
    andrew = User.find(session=session, name="Andrew")

    all_users = User.all(session=session)

    for u in all_users:
      print(u.name)

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

crudal-0.2.2.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

crudal-0.2.2-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file crudal-0.2.2.tar.gz.

File metadata

  • Download URL: crudal-0.2.2.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.10.6 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for crudal-0.2.2.tar.gz
Algorithm Hash digest
SHA256 03e86657e22afb25979c5639a695b99f2b8b0ce50310f3e412e20f60a37565a4
MD5 8a9e0f13c96bcda11bf0070f67a6176c
BLAKE2b-256 15a0890ede8b7f5b63a2e7e9add8382f3003bed84294743ea5dbf1d79a882285

See more details on using hashes here.

File details

Details for the file crudal-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: crudal-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.1 CPython/3.10.6 Linux/5.15.90.1-microsoft-standard-WSL2

File hashes

Hashes for crudal-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6bac0b42e8f9ce49f8c0b3bcaa206bb648d5a35dad28cb92d65c298abc29b11a
MD5 cb6523d0c98940dcf04903f12aa27d11
BLAKE2b-256 1d6aea92ba7d9463cd74f26d9bf178e47923b3064a15945cccbf6c2d2294935f

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