Skip to main content

Ardilla ORM. Easy to use, fast to implement, with sync and async flavors

Project description

ardilla

Downloads PyPI - Python Version PyPI GitHub

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 and intricate relationships.

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 conflict
  • crud.insert_or_ignore Inserts a record or silently ignores if it already exists
  • crud.save_one upserts an object
  • crud.save_many upserts many objects
  • crud.get_all equivalent to SELECT * FROM tablename
  • crud.get_many returns all the objects that meet criteria
  • crud.get_or_create returns an tuple of the object and a bool, True if the object was newly created
  • crud.get_or_none Returns the first object meeting criteria if any
  • crud.delete_one Deletes an object
  • crud.delete_many Deletes many objects

Examples:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ardilla-0.0.16a0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

ardilla-0.0.16a0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file ardilla-0.0.16a0.tar.gz.

File metadata

  • Download URL: ardilla-0.0.16a0.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for ardilla-0.0.16a0.tar.gz
Algorithm Hash digest
SHA256 692a5004cba408ceb56b78afe0e13ca1e2dfb534eb1dfcbbf4121587371a40a6
MD5 4383a713a4322c982318db135e639a99
BLAKE2b-256 9f440f62863c9546e5d3df03100d3e4d286b60b5a41c2dc7adf2ab3ead2ec934

See more details on using hashes here.

File details

Details for the file ardilla-0.0.16a0-py3-none-any.whl.

File metadata

  • Download URL: ardilla-0.0.16a0-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for ardilla-0.0.16a0-py3-none-any.whl
Algorithm Hash digest
SHA256 46ee01758f2793eb6bc307270048fa220db2fff1d72e0581fc35395fd0d5dcd2
MD5 6c6d7d130811fdc5f81059b4cf1bd48c
BLAKE2b-256 83057a62a258a41a2c116cc7ee1b20edbe119d24d0e94351e62d5133cf9ffa61

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page