SQLAlchemy Crud
sqlalchemy-crud is a Python library that takes the pain out of performing common CRUD operations on SQLAlchemy models. It provides a simple and intuitive interface to create, read, update, and delete records in your database.
Table of Contents
- Installation
- Usage Examples
- Getting Started
- Contributing
- Testing
- Compatibility
- License
- Versioning
- Authors and Acknowledgments
Installation
You can easily install sqlalchemy-crud using Poetry, a dependency management tool for Python:
$ poetry add sqlalchemy-crud
Make sure you have Python 3.8, 3.9, 3.10, or 3.11 installed.
Usage Examples
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from sqlalchemy_crud import crud
from my_app.models import MyModel
# Set up the SQLAlchemy session
engine = create_engine("sqlite:///database.db")
Session = sessionmaker(bind=engine)
db = Session()
# Create a new object
model = crud.create_model(db, MyModel, schema={"name": "John Doe"})
# Retrieve all objects
models = crud.get_models(db, MyModel)
# Retrieve an object by ID
model = crud.get_model(db, MyModel, model_id=1)
# Retrieve objects by a specific attribute
models = crud.get_models_by_attribute(db, MyModel, attribute="name", value="John Doe")
model = crud.get_model_by_attribute(db, MyModel, attribute="uuid", value="123e4567-e89b-12d3-a456-426614174000")
# Update an object
model = crud.update_model(db, MyModel, model_id=1, schema={"name": "Jane Doe"})
# Delete an object
crud.delete_model(db, MyModel, model_id=1)
Getting Started
To get started with sqlalchemy-crud, follow these steps:
- Install the library using the instructions provided in the Installation section.
- Import the necessary modules and create a SQLAlchemy session.
- Use the CRUD functions (
create_model,get_model,update_model,delete_model, etc.) to perform operations on your SQLAlchemy models. - Refer to the Usage Examples section for more detailed examples and code snippets.
Contributing
I welcome contributions from the community! If you'd like to contribute to sqlalchemy-crud, please follow the guidelines outlined in CONTRIBUTING.md.
Testing
To run the tests for sqlalchemy-crud, execute the following command:
$ poetry run pytest
Compatibility
sqlalchemy-crud is compatible with Python 3.8, 3.9, 3.10, and 3.11. It works with SQLAlchemy 1.3.19 up to but excluding (<) 2.
License
This library is released under the MIT License. See the LICENSE file for more details.
Versioning
this project follows semantic versioning for sqlalchemy-crud releases.
Authors and Acknowledgments
sqlalchemy-crud is maintained by Clayton Black.
Thank you to all the contributors to open-source software.
Not only do I use a lot of it, but I learn a lot from it as well.
I hope you find sqlalchemy-crud useful in your projects and appreciate your feedback and contributions!
Metadata
Release files for sqlalchemy-crud 0.2.2
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 | Actions |
|---|---|---|---|---|
| sqlalchemy_crud-0.2.2.tar.gz | 3.9 kB | Without provenance | Details for sqlalchemy_crud-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sqlalchemy_crud-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for sqlalchemy_crud-0.2.2-py3-none-any.whl |
Total release size: 8.4 kB
Release files / sqlalchemy_crud-0.2.2.tar.gz
| Download URL | sqlalchemy_crud-0.2.2.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8176910c910b8cdcaa4843f2d426d09044a9f9b6e993edd0fedaffe2d2e24b17
|
|
BLAKE2b-256 checksum How to use checksums |
27de7b61936ae59b8cca28fb51523788ac346e550c93e3e47b5de90665da8b22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1042-azure
|
Release files / sqlalchemy_crud-0.2.2-py3-none-any.whl
| Download URL | sqlalchemy_crud-0.2.2-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9a3e2559e70140eccdf70f9700018a4a6efdd9cb5497a22fa2a8e26f17a10d9c
|
|
BLAKE2b-256 checksum How to use checksums |
ec24fe3cc5853486fcf66922ed73723e73d11b1c525c642576d946fa80ce6aed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1042-azure
|
Security for sqlalchemy-crud 0.2.2
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.