Ardilla ORM. Easy to use, fast to implement, with sync and async flavors
Project description
ardilla
Ardilla (pronounced ahr-dee-yah) means "SQuirreL" in spanish.
A very simple library to quickly add SQLite to your program. It leverages pydantic for data validation and modeling. It comes in sync (sqlite3) and async (aiosqlite) flavors.
Who and what is this for:
For developers seeking a simple and straightforward way to incorporate a SQLite database into their applications, our library is an excellent option. It offers a user-friendly solution that is both fast and easy to use.
While this library may not be suitable for those who require more complex querying and intricate relationships, it excels in its simplicity and ease of implementation.
For developers who desire more advanced features, there are other libraries available, such as tortoise-orm, sqlalchemy, pony or peewee.
install
Install lastest release from PyPi
pip install -U ardilla
pip install -U ardilla[async]
pip install -U ardilla[dev]
- async instaslls aiosqlite
- dev installs formatting and testing dependencies
Or install the lastest changes directly from github
pip install git+https://github.com/chrisdewa/ardilla.git
pip install git+https://github.com/chrisdewa/ardilla.git#egg=ardilla[async]
pip install git+https://github.com/chrisdewa/ardilla.git#egg=ardilla[dev]
How to use:
from ardilla import Engine, Model, Crud
from pydantic import Field
engine = Engine('db.sqlite3')
class User(Model):
id: int = Field(primary=True, autoincrement=True)
name: str
age: int
user_crud = engine.crud(User)
def main():
engine.setup() # creates tables
# get or none
user = user_crud.get_or_none(id=1)
# get or create
user2, was_created = user_crud.get_or_create(id=2, name='chris', age=35)
# save one
user3 = User(id=3, name='moni', age=35)
user_crud.save_one(user3)
# save many
user_crud.save_many(user, user2, user3)
# get many
users = user_crud.get_many(age=35)
Supported CRUD methods:
crud.insert
Inserts a record, rises errors if there's a conflictcrud.insert_or_ignore
Inserts a record or silently ignores if it already existscrud.save_one
upserts an objectcrud.save_many
upserts many objectscrud.get_all
equivalent toSELECT * FROM tablename
crud.get_many
returns all the objects that meet criteriacrud.get_or_create
returns an tuple of the object and a bool, True if the object was newly createdcrud.get_or_none
Returns the first object meeting criteria if anycrud.delete_one
Deletes an objectcrud.delete_many
Deletes many objects
Examples:
To-dos
- Add testing
- Add a schema generator
- Docstring everything using Google format
- Add proper documentation
- propper as in a site with how to use
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 ardilla-0.0.10a0.tar.gz
.
File metadata
- Download URL: ardilla-0.0.10a0.tar.gz
- Upload date:
- Size: 14.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 619a701f43cea72e0d6630c11cab324c98a54df2144aa99dec831c591817b0d2 |
|
MD5 | af52b4fe33680a0ecb3e27137a13b7ec |
|
BLAKE2b-256 | 3c6a667d7df76060c7dccfb79601f8164aee743778bad829d42baf09fbc4cafa |
File details
Details for the file ardilla-0.0.10a0-py3-none-any.whl
.
File metadata
- Download URL: ardilla-0.0.10a0-py3-none-any.whl
- Upload date:
- Size: 15.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fb0126f8266a97382512e75737fd074db4e0550b5174137685d7b95131cba69 |
|
MD5 | a8a07e65014cbe5c01bb1f14a36f26d6 |
|
BLAKE2b-256 | 077f75fc4aeb9e36bf2e334abec85197b5cfb27a138b32bb88db17256074c91c |