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.0.tar.gz
(3.9 kB
view details)
Built Distribution
File details
Details for the file crudal-0.2.0.tar.gz
.
File metadata
- Download URL: crudal-0.2.0.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd92b98dd0abd89653c0f7aa8d6a3df77ec5c43015f45a307241d1a1da049701 |
|
MD5 | 7082bccef1fca33c661fb91dbe86665a |
|
BLAKE2b-256 | aed4a6bc672f40c5e16ff5ba7233c09823e5b5b19fd465c4e9b97a07e0490b3b |
File details
Details for the file crudal-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: crudal-0.2.0-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5546de7800b9b96150c8fd2a97dabcb844e2f2316fdd79509d89e7067be8a052 |
|
MD5 | 83653e9f12e35d6490a6d76f73d77c45 |
|
BLAKE2b-256 | 0fc23364e6794bbc26e70993be2ff50ae30991e059c2ba8fd931c75a4d5fc13d |