Skip to content
GitHub

Quickstart

Terminal window
uv add lexigram-sql

lexigram (core) and lexigram-contracts are pulled in automatically. For Postgres or MySQL, add the driver extra:

Terminal window
uv add "lexigram-sql[postgres]" # asyncpg
uv add "lexigram-sql[mysql]" # aiomysql

Configure a database and boot it with DatabaseModule:

import asyncio
from lexigram import Application
from lexigram.sql import DatabaseModule
async def main():
async with Application.boot(
name="my-app",
modules=[DatabaseModule.configure("sqlite+aiosqlite:///example.db")],
) as app:
print("Database connected")
asyncio.run(main())

from dataclasses import dataclass
from lexigram.domain import DomainModel
from lexigram.sql import GenericRepository
@dataclass
class User(DomainModel):
id: int | None = None
name: str = ""
email: str = ""
repo = GenericRepository[User, int](
provider=db_provider, # resolved from container
table_name="users",
entity_class=User,
key_field="id",
)

  • Guide — mental model, repositories, queries, migrations
  • How-Tos — task-oriented recipes
  • Configuration — every config key