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.1.tar.gz
(3.9 kB
view details)
Built Distribution
File details
Details for the file crudal-0.2.1.tar.gz
.
File metadata
- Download URL: crudal-0.2.1.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 | 334fc9d977aaa69a4e4e6c8f94cd0311fd6e03565805b70aae9c66f9e8595e03 |
|
MD5 | d9df2189706e84f06222209759511193 |
|
BLAKE2b-256 | d68f5276a5707453e7b713ff680311ea8b94c636d457457188a93daa200497a4 |
File details
Details for the file crudal-0.2.1-py3-none-any.whl
.
File metadata
- Download URL: crudal-0.2.1-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 | d4ca8178c6ef29d9766994872b11ceb93bbbf676620fd8b30599763d3be6c355 |
|
MD5 | eccae2a6e146e0c4d0877376ff79d6fa |
|
BLAKE2b-256 | 2d3cdc63b35c1d53c60c366ad231ef6cd48921e2a6c998b2baae58eb5c0ee626 |