SimpleCRUD
SimpleCRUD is a library that provides a simple way to create CRUD commands for SQLAlchemy models.
Installation
pip install hexfrost-simplecrud
poetry add hexfrost-simplecrud
Usage
- Create a model
- Create a sessionmaker from SQLAlchemy
- Import CRUD functions
- Use CRUD functions and enjoy
Example usage
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession, async_sessionmaker
from sqlalchemy.orm import DeclarativeBase
from simplecrud import get_all, create_obj, update_obj, delete_object
engine = create_async_engine("sqlite+aiosqlite:///test.db", echo=True)
session = async_sessionmaker(async_engine, expire_on_commit=False, class_=AsyncSession)
# Create a model
class ExampleModel(DeclarativeBase):
__tablename__ = "example_model"
id = Column(Integer, primary_key=True)
name = Column(String(50), nullable=False)
description = Column(String(50), nullable=False)
async def example_func():
# Create a model
new_model = await create_object(model, name="test", description="test", conn=session())
# Get all models
all_objs = await get_all(model, conn=session())
# Update a model
updated_obj = await update_object(model, name="test2", description="test2", conn=session())
# Delete a model
await delete_object(model, name="test2", description="test2", conn=session())
Avaliable functions:
get_object- get a single objectget_all- get all objectsget_all_with_filter- get all objects with filterget_objects- get all objects with filter, limit and offsetget_or_create_object- get or create an objectcreate_object- create an objectbulk_create- create multiple objectsupdate_object- update an objectupdate_or_error- update an object or raise an errorupdate_object_by_id- update an object by idupdate_or_create_object- update or create an objectdelete_object- delete an objectdelete_object_by_id- delete an object by idbulk_delete- bulk delete objectsbulk_delete_by_id- bulk delete objects by id
Contributing
This project is open for contributions. Feel free to open an issue or create a pull request.
License
GNU GENERAL PUBLIC LICENSE Version 3
Metadata
Release files for hexfrost-simplecrud 0.3.0
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 | |
|---|---|---|---|---|
| hexfrost_simplecrud-0.3.0.tar.gz | 18.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hexfrost_simplecrud-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 37.4 kB
Release files / hexfrost_simplecrud-0.3.0.tar.gz
| Download URL | hexfrost_simplecrud-0.3.0.tar.gz |
|---|---|
| Size | 18.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aca47b11ddb841e9c76900a53e3eda00ddb079bb203d6c556a417168485db718
|
|
BLAKE2b-256 checksum How to use checksums |
9466953535d066e87b0afb553f369760e2e185fda6c52518514a26a8cdc72dba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.2 Linux/6.5.0-1015-azure
|
Release files / hexfrost_simplecrud-0.3.0-py3-none-any.whl
| Download URL | hexfrost_simplecrud-0.3.0-py3-none-any.whl |
|---|---|
| Size | 19.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a8cd101a6eb5ab65ba733d8824a544792126d6ad1cc2e5024bf83c0552a6c0a5
|
|
BLAKE2b-256 checksum How to use checksums |
d3c96c5adbdabae8403caa61472a32240589878777ca84d091b2b2395802db25
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.12.2 Linux/6.5.0-1015-azure
|
Security for hexfrost-simplecrud 0.3.0
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.