Simple ORM based on Pydantic and SQLite with minimalistic API
Project description
ORMagic - Simple ORM for Python
The main goal of ORMagic is to provide a simple and easy-to-use ORM for Python, that is easy to understand and use, while still providing the necessary features to interact with a database. The library is in the early stages of development, so it is not recommended to use it in production. Is based on the Pydantic model and extends it with the ability ti save, read, update and delete data from a SQLite database.
Installation
pip install ORMagic
Usage
from ormagic import DBModel
class User(DBModel):
name: str
age: int
created_at: datetime = datetime.now()
# Create the table in the database
User.create_table()
# Save data to the database, this will create a new record or update an existing one if the primary key is already present
user = User(name="John", age=30)
user.save()
# Read data from the database
user = User.get(id=1)
print(user)
>>> User(id=1, name='John', age=30, created_at=datetime.datetime(2021, 10, 10, 12, 0, 0))
# Delete data from the database
user.delete()
Features and Roadmap
- Define table schema using Pydantic models
- Basic CRUD operations
- Save data to the database
- Read data from the database
- Update data in the database
- Delete data from the database
- Custom primary key
- Bulk operations (save, update, delete)
- Relationships between tables
- One-to-one
- One-to-many
- Many-to-many
- Migrations
License
This project is licensed under the terms of the MIT license
Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request.
Why?
There are many ORMs for Python, but most of them are too complex or have too many features that are not needed for simple projects.
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
File details
Details for the file ormagic-0.1.0.tar.gz
.
File metadata
- Download URL: ormagic-0.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1023-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a3ded1ca1b8aa26e34548688af44174a8f7a1b252140f5dbb4758116f6cf113 |
|
MD5 | 5494d377ec84dd50042185a8bbe5ed4f |
|
BLAKE2b-256 | 3ff26d069a50e528d7072a1dfd315c4a3e90740924202ece2e2e9a63718c792f |
File details
Details for the file ormagic-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: ormagic-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1023-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd459581458ec2bd0c9770d9cf1426505760079abcfa59ea3cf884cdf433ceba |
|
MD5 | fffd9d1c7a46db44646ba52bdf90f6d8 |
|
BLAKE2b-256 | ea5e7522ca82fcd82ce81e0598a8f8b8ba84d3ab7809600eb276adb9eec63e32 |