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.1.0.tar.gz
(3.3 kB
view details)
Built Distribution
File details
Details for the file crudal-0.1.0.tar.gz
.
File metadata
- Download URL: crudal-0.1.0.tar.gz
- Upload date:
- Size: 3.3 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 | 044eb9d7ea5ec43ccc0e40ae66b79848af6a9c1739593d327955f70915fa247d |
|
MD5 | 47b1d7130b21efaeb00c6bc440357316 |
|
BLAKE2b-256 | ee62edca9cfc8774c8ea93a68456fa481f74e55bfd73ba91538118434c3467c6 |
File details
Details for the file crudal-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: crudal-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 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 | 0ba62d3db2d1721ec32fc5f9ab6cbae7c1415a4d5be886f010763dd68356b3d2 |
|
MD5 | 74da6f9111d695faefeaab4fb5d9c64c |
|
BLAKE2b-256 | 30abc7c49b96ea138dea3043fcdc6b93d9e6b4eac06e2a2c5fb0a9f834b8c2e3 |