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.
This library aims to be a simple way to add an SQLite database and basic C.R.U.D. methods to python applications. It uses pydantic for data validation and supports a sync engine as well as an async (aiosqlite) version.
Who and what is this for
This library is well suited for developers seeking to incorporate SQLite into their python applications to use simple C.R.U.D. methods. It excels in its simplicity and ease of implementation while it may not be suitable for those who require more complex querying, intricate relationships or top performance.
For developers who desire more advanced features, there are other libraries available, such as tortoise-orm, sqlalchemy, pony or peewee.
Links
Find Ardilla's source code here
Documentation can be accessed here
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
class User(Model):
id: int = Field(primary=True, autoincrement=True)
name: str
age: int
def main():
with Engine('db.sqlite') as engine:
user = crud.get_or_none(id=1) # user with id of 1
user2, was_created = crud.get_or_create(id=2, name='chris', age=35)
users = crud.get_many(name='chris') # all users named chris
user3 = User(id=3, name='moni', age=35)
user.age += 1 # it's her birthday
crud.save_one(user3)
crud.save_many(user, user2, user3)
Supported CRUD methods:
crud.insertInserts a record, rises errors if there's a conflictcrud.insert_or_ignoreInserts a record or silently ignores if it already existscrud.save_oneupserts an objectcrud.save_manyupserts many objectscrud.get_allequivalent toSELECT * FROM tablenamecrud.get_manyreturns all the objects that meet criteriacrud.get_or_createreturns an tuple of the object and a bool, True if the object was newly createdcrud.get_or_noneReturns the first object meeting criteria if anycrud.delete_oneDeletes an objectcrud.delete_manyDeletes many objects
Examples:
- A simple FastAPI application
- A reputation based discord bot
- basic usage
- basic usage with foreign keys
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 ardilla-0.4.0b0.tar.gz.
File metadata
- Download URL: ardilla-0.4.0b0.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62a638c0cdb1afe387e2b08097a48c07a590bc08a581e134cbedfd6d1d8b2ee2
|
|
| MD5 |
5f200c1ac7a41bc33b23d2716a4323d5
|
|
| BLAKE2b-256 |
e56a7aeeda56b723d3e1d1fa6b149f0da0b8e810d73afdc4743fd8fa6b7d7c57
|
File details
Details for the file ardilla-0.4.0b0-py3-none-any.whl.
File metadata
- Download URL: ardilla-0.4.0b0-py3-none-any.whl
- Upload date:
- Size: 22.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
400302b5980adf168503800e2c12ccc842cbbcaa7e71cc315d63ff3346080f8a
|
|
| MD5 |
12ae9de4fbc47bf73e2e49dd1866ffb1
|
|
| BLAKE2b-256 |
bc98f49ba048d74cd198e46375562a066fd6860d979fb25f3e56ecbc170cbf6c
|