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 v2 for data validation and supports both a sync engine and an async (aiosqlite) version.
This library is well suited for developers seeking to incorporate SQLite into their Python applications using simple C.R.U.D. methods. It excels in its simplicity and ease of implementation, but may not be suitable for those who require complex querying, intricate relationships, or top performance.
For more advanced features, consider tortoise-orm, sqlalchemy, pony, or peewee.
Source code: github.com/chrisdewa/ardilla
Documentation: ardilla.rtfd.io
Install the latest release from PyPI:
pip install -U ardilla
pip install -U ardilla[async] # includes aiosqlite
pip install -U ardilla[dev] # includes formatting and testing dependenciesOr install the latest 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]from ardilla import Engine, Model, Field
class User(Model):
id: int = Field(pk=True, auto=True)
name: str
age: int
with Engine('db.sqlite') as engine:
crud = engine.crud(User)
user = crud.get_or_none(id=1)
user2, was_created = crud.get_or_create(id=2, name='chris', age=35)
users = crud.get_many(name='chris')
user3 = User(id=3, name='moni', age=35)
user2.age += 1
crud.save_one(user3)
crud.save_many(user2, user3)crud.insert— inserts a record, raises an error on conflictcrud.insert_or_ignore— inserts a record, silently ignores if it already existscrud.save_one— upserts a single objectcrud.save_many— upserts multiple objectscrud.get_all— equivalent toSELECT * FROM tablenamecrud.get_many— returns all objects matching the given criteriacrud.get_or_create— returns a tuple of(object, created: bool)crud.get_or_none— returns the first matching object, orNonecrud.delete_one— deletes a single objectcrud.delete_many— deletes multiple objects
- A simple FastAPI application
- A reputation-based Discord bot
- Basic usage
- Basic usage with foreign keys