Skip to main content

ormic

A simple, asynchronous python ORM for SQLite databases

Installation

# stable
$ pip install ormic

# unstable
$ pip install git+https://github.com/Dorukyum/ormic

Quickstart

from ormic import Database, Model

db = Database()

# create a model
@db.model
class Point(Model):
    name: str
    x: int
    y: int = 5  # default value

# connect to a database
await db.connect("database.db")

Database Actions

# create an object
point = Point(name="A", x=5, y=10)
await point.save()

# fetch objects from the database
point_named_A: Point | None                = await Point.fetch(name="A")
list_of_points_named_A: list[Point] | None = await Point.fetch_all(name="A")

# update an object
await point.update(y=15)
# or
point.y = 15
await point.update()

# delete an object
await point.delete()

Caching

# turn caching on
# setting limit to 20 will only cache the last fetched 20 objects
# this parameter defaults to None, caching all fetched objects
database.set_caching(on=True, limit=20)

# get the object from the cache
# will fetch from the database if no matches found
point_named_A = await Point.get_or_fetch(name="A")

Release files for ormic 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ormic 1.0.0
File Size Uploaded
ormic-1.0.0.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ormic 1.0.0
File Interpreter ABI Platform
ormic-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 13.5 kB

Release files / ormic-1.0.0.tar.gz

Download URL ormic-1.0.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
8f8fb0969fb1a7c81a730dcc4be433bbe4cdd9568e7319e9de674cc357d88c99
BLAKE2b-256 checksum
How to use checksums
6582e6d08c3889ae38cd28e243d552e92ce7a81cb99121fefd4a08027d4f2104
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release files / ormic-1.0.0-py3-none-any.whl

Download URL ormic-1.0.0-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d94c019419d561785bddfe4d990a7feb39cd770b43d64946bf70e0e34d7d418
BLAKE2b-256 checksum
How to use checksums
b759821f9801d941d841509bb8375d5e8e1eb8aab978a7c592d3e67ca05eb724
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.5

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page