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.6.tar.gz (8.1 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.6-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for aiosqlite_strict-1.0.6.tar.gz
Algorithm Hash digest
SHA256 50369a763023fcda68502f2e39b4449ce76ef5291d5f20bbea8df1269a5e98a3
MD5 b6541605231682570e8b85c4dc1bfdc9
BLAKE2b-256 af4ae3ae83fa03bd506a99b115a72ef3edd1e11cf827e0783de749cd99bae84c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for aiosqlite_strict-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1e422c0052b9eb258e2daf18c809de47b5e06ae62da0cd51d3bdb204ff454783
MD5 bf110b4758fb9e54521ed0bdfde80ac6
BLAKE2b-256 bc3ed8184c3dc517a100bf909817d4d162f4883b4b0b522958e7a470f4afe33a

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