Skip to main content

LiteModel

Install

pip install litemodel

Usage

Sync

# import Model
from litemodel.core import Model


# Define the Model
class Note(Model):
    title: str
    text: Optional[str]
    archived: bool = False

# Create the table in sqlite
Note.create_table()

# Create an instance
note = Note(title="Test", text="Just Testing")
note.save()

# Get the note
note = Note.find_by("title", "Test")

# Update the note
note.text = "Updating the note"
note.save()

Async

# import Model
from litemodel.async_core import Model


# Define the Model
class Note(Model):
    title: str
    text: Optional[str]
    archived: bool = False

# Create the table in sqlite
await Note.create_table()

# Create an instance
note = Note(title="Test", text="Just Testing")
await note.save()

# Get the note
note = await Note.find_by("title", "Test")

# Update the note
note.text = "Updating the note"
await note.save()

Example Project

I used this to build a CLI note app you can see here: https://github.com/psqnt/notes

look in the __main__.py file for some queries / instance creation and look in db.py for how to handle database creation / connection

Configuration

You can set some environment variables to control behavior

set where litemodel will look for your database

export DATABASE_PATH=/path/to/my/db/sqlite.db

set to debug mode

export LITEMODEL_DEBUG=True

Note

This was written fairly quickly and is lacking some functionality that I hopefully can get to soon. However, its a very small project so should be easy to update if you want to fork. Also its easily extensible to make better queries when needed

Metadata

Release files for litemodel 0.1.11

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

Source distribution (sdist)

Source distribution for litemodel 0.1.11
File Size Uploaded Provenance Actions
litemodel-0.1.11.tar.gz 21.9 kB Without provenance Details for litemodel-0.1.11.tar.gz

Built distribution (wheel)

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

Total release size: 31.6 kB

Release files / litemodel-0.1.11.tar.gz

Download URL litemodel-0.1.11.tar.gz
Size 21.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9d33df317dd392ca32b982329586cc3ff80a420928537ffdd6ee37ee1d42c9f5
BLAKE2b-256 checksum
How to use checksums
c6048125a324f820d2fdad34fbadfda14147041202bce5bb19e64a49c2a8c574
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.13

Release files / litemodel-0.1.11-py3-none-any.whl

Download URL litemodel-0.1.11-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a463bad1568e03c89b2760ba136472d463797c3b67ba27eacc377e3d5b78fbd9
BLAKE2b-256 checksum
How to use checksums
7f513aaa55b9ab6a814a53dbdcd13d95d2adfa3af02bd0e10e614f6710ce2b71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.13

Security for litemodel 0.1.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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