CRUDAL
Ready to use CRUD methods for SQLAlchemy models. Both Sync and Async
pip install crudal
Examples
Sync
Model initialization
from crudal import DeclarativeCrudBase
from sqlalchemy import Integer, String, create_engine
from sqlalchemy.orm import Mapped, mapped_column, sessionmaker
engine = create_engine("sqlite://")
SessionLocal = sessionmaker(engine, expire_on_commit=False)
class User(DeclarativeCrudBase):
__tablename__ = "person"
__session__ = sessionmaker(engine, expire_on_commit=False)
id: Mapped[int] = mapped_column(Integer, primary_key=True)
name: Mapped[str] = mapped_column(String, nullable=False)
DeclarativeCrudBase.metadata.create_all(bind=engine)
Add new item
user = User(name="Andrew")
user.add()
Find item
Find all users with name equals Andrew
users_found = User.find(name="Andrew")
for u in users_found:
assert u.name == "Andrew"
Update item
Change name of all users with name Andrew to John
User.update(session=session, values=dict(name="John"), name="Andrew")
Delete item
User.delete(name="John")
Async
from crudal import DeclarativeCrudBaseAsync
from sqlalchemy import Integer, String, create_engine
from sqlalchemy.orm import Mapped, Session, mapped_column
class User(DeclarativeCrudBaseAsync):
__tablename__ = "person"
id: Mapped[int] = mapped_column(Integer, primary_key=True)
name: Mapped[str] = mapped_column(String, nullable=False)
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)
Metadata
Release files for crudal 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| crudal-0.3.1.tar.gz | 5.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| crudal-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.9 kB
Release files / crudal-0.3.1.tar.gz
| Download URL | crudal-0.3.1.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f2b6468363f2a113b29fc365c79a0eb6ae933f91c91f8376cd85a1e00709c47
|
|
BLAKE2b-256 checksum How to use checksums |
edbead444b8113b4dcab995272c702e14db11cb34b0008c43a539c873e591300
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.10.6 Linux/5.15.90.1-microsoft-standard-WSL2
|
Release files / crudal-0.3.1-py3-none-any.whl
| Download URL | crudal-0.3.1-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
713f57cb10cee9847cf9c50fa50d92d6230ea8dd2f4c0dd7ad2368eae4c10c5b
|
|
BLAKE2b-256 checksum How to use checksums |
42190fa0c7046090f63851bc1c3677b58285f0224e301b3b519b9bb05bbb78f9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.4.1 CPython/3.10.6 Linux/5.15.90.1-microsoft-standard-WSL2
|
Security for crudal 0.3.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.