Mixins for sqlalchemy and pydantic
Project description
Mixemy
Mixemy is a small library providing a set of mixins for SQLAlchemy and Pydantic to simplify common CRUD operations, validation, and schema management.
Features
- Models: Base classes and mixins that extend SQLAlchemy
declarative_base()models with useful fields like IDs and timestamps. - Schemas: Pydantic schemas for input validation, serialization, and more.
- CRUD: Generic CRUD classes that can be extended to handle common database interactions—create, read, update, and delete.
Installation
pip install mixemy
or, if you prefer Poetry:
poetry add mixemy
Quick Start
Below is a minimal example demonstrating how to use mixemy to create a SQLAlchemy model, corresponding Pydantic schemas, and a CRUD class:
from sqlalchemy.orm import Mapped, mapped_column
from sqlalchemy import String
from mixemy import crud, models, schemas
# Define a SQLAlchemy model with some default fields (e.g., id, created_at, updated_at)
class ItemModel(models.IdAuditModel):
value: Mapped[str] = mapped_column(String)
# Define Pydantic schemas for input and updates
class ItemInput(schemas.InputSchema):
value: str
class ItemUpdate(schemas.InputSchema):
value: str
# Extend the generic CRUD class to specify the model and schemas
class ItemCRUD(crud.IdAuditCRUD[ItemModel, ItemInput, ItemUpdate]):
pass
# Instantiate the CRUD class with the model
item_crud = ItemCRUD(ItemModel)
Explanation
-
ItemModel
Inherits frommodels.IdAuditModel, which provides default columns such asid,created_at, andupdated_at. We add our ownvaluefield as aString. -
ItemInput&ItemUpdate
These are Pydantic schemas that extendschemas.InputSchema. Use these for type-safe request inputs in create and update operations. -
ItemCRUD
Extendscrud.IdAuditCRUD, which already implements generic CRUD operations (likecreate,read,update,delete) for our model and schemas. You can override these methods if you need custom behavior.
Why Use Mixemy?
- Speed up development by reducing boilerplate for common operations.
- Stay type-safe with Pydantic schemas and generics in CRUD classes.
- Extensible—override base classes or methods to customize or add new functionality.
- Built for maintainability with consistent code structure and naming.
License
This project is licensed under the MIT License.
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub if you have suggestions or feature requests.
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Commit your changes.
- Push to your branch and open a pull request.
Happy coding with Mixemy! If you find this library helpful, feel free to star it on GitHub or contribute.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mixemy-0.1.2.tar.gz.
File metadata
- Download URL: mixemy-0.1.2.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
013f5c513bce3a0df010130b28e0fee687bb962be9103de699e4e1a1f32414f6
|
|
| MD5 |
65e85d61d40572db846d47fb433088e7
|
|
| BLAKE2b-256 |
2f0d54dffd3bab11e6448a16b85cab266f477ff20def7bccfb6448403fcbc712
|
Provenance
The following attestation bundles were made for mixemy-0.1.2.tar.gz:
Publisher:
cd.yml on frostyfeet909/mixemy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mixemy-0.1.2.tar.gz -
Subject digest:
013f5c513bce3a0df010130b28e0fee687bb962be9103de699e4e1a1f32414f6 - Sigstore transparency entry: 159751362
- Sigstore integration time:
-
Permalink:
frostyfeet909/mixemy@ac7e8fc6867ac066c052fb913591b67ec3de5e1f -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/frostyfeet909
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@ac7e8fc6867ac066c052fb913591b67ec3de5e1f -
Trigger Event:
release
-
Statement type:
File details
Details for the file mixemy-0.1.2-py3-none-any.whl.
File metadata
- Download URL: mixemy-0.1.2-py3-none-any.whl
- Upload date:
- Size: 13.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
899c693ff6c08555df21772a423cbb716154899c56065dd1410f240b82db3fcc
|
|
| MD5 |
e1327baf077775ae5754163e86f424ec
|
|
| BLAKE2b-256 |
e88ab43f32935b740a54c6ddeee15dec7ed89f718ff70e5e686cbaa7ea6d1675
|
Provenance
The following attestation bundles were made for mixemy-0.1.2-py3-none-any.whl:
Publisher:
cd.yml on frostyfeet909/mixemy
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mixemy-0.1.2-py3-none-any.whl -
Subject digest:
899c693ff6c08555df21772a423cbb716154899c56065dd1410f240b82db3fcc - Sigstore transparency entry: 159751364
- Sigstore integration time:
-
Permalink:
frostyfeet909/mixemy@ac7e8fc6867ac066c052fb913591b67ec3de5e1f -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/frostyfeet909
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
cd.yml@ac7e8fc6867ac066c052fb913591b67ec3de5e1f -
Trigger Event:
release
-
Statement type: