Skip to main content

aiosqlite + strict pydantic models

Project description

aiosqlite-strict

Strict Pydantic models on top of aiosqlite.

Install

pip install aiosqlite-strict

Usage

import asyncio

import aiosqlite
from aiosqlite_strict import TableModel

class AppTable(TableModel):
    ...

class User(AppTable):
    __indices__ = [("name",)]

    name: str
    email: str

async def main() -> None:
    async with aiosqlite.connect(":memory:") as db:
        await AppTable.sqlite_init(db)

        user1 = await User.create(db, name="name1", email="email1")
        _ = await User.create(db, name="name2", email="email2")

        async with User.select(db) as cursor:
            print(await cursor.fetchall())

        await user1.update_one(db, name="name1.1")

        async with User.select(db, "WHERE name=?", ("name1.1",)) as cursor:
            print(await cursor.fetchall())

asyncio.run(main())

Development

uv run pytest

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

aiosqlite_strict-1.0.1.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiosqlite_strict-1.0.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file aiosqlite_strict-1.0.1.tar.gz.

File metadata

  • Download URL: aiosqlite_strict-1.0.1.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.8

File hashes

Hashes for aiosqlite_strict-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e225618ffedb1f9c19943fb9b0f4582a03909cc4eb68912f266cbd4c47ca7f81
MD5 11c65c23b7c0cff655cd008086f5f28b
BLAKE2b-256 d5133249e5db7bcb8d8de4cf58a9d74ab57dc5d6a13de6bb3a300a7f131d3a3c

See more details on using hashes here.

File details

Details for the file aiosqlite_strict-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for aiosqlite_strict-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cbd3cfa41d8c554718eea4c34e4d06039971c45f8227ef7981c8c703658e2d60
MD5 1412c2a43fddc35c2dc0dc1da638c35d
BLAKE2b-256 662c420f9ace2039056ec20889c9bebad054e65c053cf2c68ae2c76083961bb5

See more details on using hashes here.

Supported by

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