API Reference
This section provides detailed documentation for every public class, method, property, function, and constant in the SQLiter library. Each entry includes the full signature, parameter descriptions, return types, and usage examples.
Tip
If you are new to SQLiter, start with the Guide for a tutorial-style introduction. This API Reference is intended as a comprehensive lookup resource.
Module Overview
| Module | Import | Description |
|---|---|---|
sqliter | from sqliter import SqliterDB | Main database class |
sqliter.model | from sqliter.model import BaseDBModel | Base model (legacy mode) |
sqliter.model | from sqliter.model import unique | Unique constraint helper |
sqliter.model | from sqliter.model import ForeignKey | Foreign key factory (legacy mode) |
sqliter.orm | from sqliter.orm import BaseDBModel | Base model (ORM mode) |
sqliter.orm | from sqliter.orm import ForeignKey | Foreign key descriptor (ORM mode) |
sqliter.orm | from sqliter.orm import ManyToMany | Many-to-many descriptor (ORM mode) |
sqliter.orm | from sqliter.orm import ModelRegistry | Model registry |
sqliter.asyncio | from sqliter.asyncio import AsyncSqliterDB | Async database and query API |
sqliter.asyncio.orm | from sqliter.asyncio.orm import AsyncBaseDBModel | Async ORM mode |
sqliter.query | from sqliter.query import func | QueryBuilder aggregate helpers |
sqliter.query | from sqliter.query import AggregateSpec | Aggregate specification type |
sqliter.exceptions | from sqliter.exceptions import ... | Exception hierarchy |
sqliter.helpers | (internal) | Utility functions |
sqliter.constants | (internal) | Constant mappings |
Note
The ORM module (sqliter.orm) is an alternative import mode that extends the legacy sqliter.model with lazy loading and reverse relationships. See ORM Mode for details.
Note
The async API lives under sqliter.asyncio and sqliter.asyncio.orm. Forward FK lazy loading is explicit in async ORM: author = await book.author.fetch().
Pages
- SqliterDB -- Main entry point for all database operations: connections, tables, CRUD, caching, and transactions.
- BaseDBModel -- Pydantic-based base class for defining database models, plus the
unique()constraint helper.
- QueryBuilder -- Fluent API for filtering, grouping, aggregate projections, ordering, paginating, and query execution.
- Foreign Keys --
ForeignKey()factory function,ForeignKeyInfodataclass, andFKActiontype alias (legacy mode).
- ORM Mode -- Extended
BaseDBModelwith lazy loading,ForeignKeydescriptor,LazyLoader,ModelRegistry,ReverseQuery, andReverseRelationship.
- Many-to-Many --
ManyToManydescriptor,ManyToManyManagerAPI, reverse accessors, and junction tables.
- AsyncSqliterDB -- Async database entry point, async CRUD, and async table operations.
- AsyncQueryBuilder -- Async query execution, eager loading, aggregates, and bulk query operations.
- Async ORM --
AsyncBaseDBModel,AsyncForeignKey, async reverse relationships, and async many-to-many managers.
- Exceptions -- Full hierarchy of 17 exception classes with message templates and usage context.
- Helpers & Constants -- Internal utility functions and constant mappings used by the library.