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.
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
crud = engine.crud(User)
def main():
# get or none
user = crud.get_or_none(id=1) # user with id of 1
# get or create
user2, was_created = crud.get_or_create(id=2, name='chris', age=35)
# get many
users = crud.get_many(name='chris') # all users named chris
# save one
user3 = User(id=3, name='moni', age=35)
user.age += 1 # it's her birthday
crud.save_one(user3)
# save many
crud.save_many(user, user2, user3)
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:
- A simple FastAPI application
- A reputation based discord bot
- basic usage
- basic usage with foreign keys
To-dos
- Add testing
- Add a schema generator
- Add filtering
- Add limiting
- Docstring everything using Google format
- Start a changelog when out of alpha
- 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.1.0b0.tar.gz
.
File metadata
- Download URL: ardilla-0.1.0b0.tar.gz
- Upload date:
- Size: 18.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cfe0a6b9e5ee040cc0ac9499d50e19d7809c5510d0d1b32153e002161e1526c |
|
MD5 | a96e161e8036a29771f4845f047edc69 |
|
BLAKE2b-256 | 367a514ef3a157986a07bc77f00f40c33b7e42588cc019b0affcad41caf88959 |
File details
Details for the file ardilla-0.1.0b0-py3-none-any.whl
.
File metadata
- Download URL: ardilla-0.1.0b0-py3-none-any.whl
- Upload date:
- Size: 18.1 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 | abbaad7d58481b420297d19a9676ca40649a0e821dfab82739fc255dfc240828 |
|
MD5 | 8554cb7e03f9ccc8b674451b69ff8425 |
|
BLAKE2b-256 | 22a1df482ef0b9e159786e027a2555110b384096cc99c86aae7f1648466b61f1 |