Skip to content

SQLiter

PyPI version   Test Suite  Linting  Type Checking  PyPI - Python Version

SQLiter is a lightweight Object-Relational Mapping (ORM) library for SQLite databases in Python. It provides a simplified interface for interacting with SQLite databases using Pydantic models. The only external run-time dependency is Pydantic itself.

It does not aim to be a full-fledged ORM like SQLAlchemy, but rather a simple and easy-to-use library for basic database operations, especially for small projects. It is NOT asynchronous and does not support complex queries (at this time).

The ideal use case is more for Python CLI tools that need to store data in a database-like format without needing to learn SQL or use a full ORM.

Caution

This project is still in the early stages of development and is lacking some planned functionality. Please use with caution - Classes and methods may change until a stable release is made. I'll try to keep this to an absolute minimum and the releases and documentation will be very clear about any breaking changes.

Also, structures like list, dict, set etc are not supported at this time as field types, since SQLite does not have a native column type for these. This is the next planned enhancement. These will need to be pickled first then stored as a BLOB in the database.

See the TODO for planned features and improvements.

Features

  • Table creation based on Pydantic models
  • Supports date and datetime fields. list/dict/set fields are planned.
  • Automatic primary key generation
  • User defined indexes on any field
  • Set any field as UNIQUE
  • CRUD operations (Create, Read, Update, Delete)
  • Chained Query building with filtering, ordering, and pagination
  • Transaction support
  • Custom exceptions for better error handling
  • Full type hinting and type checking
  • Detailed documentation and examples
  • No external dependencies other than Pydantic
  • Full test coverage
  • Can optionally output the raw SQL queries being executed for debugging purposes.

License

This project is licensed under the terms of the MIT license.