Skip to content

Releases: Code-Society-Lab/sqlmodel-toolkit

0.1.1

13 Apr 01:58

Choose a tag to compare

Improved Type Support for Model Initialization

Resolved IDE/type checker warnings such as Unresolved argument when creating model instances (e.g., User(name="Alice")).

What Changed

Added a model.pyi type stub that explicitly declares Model as inheriting from SQLModel. This allows type checkers to correctly infer constructor arguments from model fields when using the custom metaclass.

Impact

  • Better autocompletion and type checking
  • No runtime changes
  • No migration required

Full Changelog: https://github.com/Code-Society-Lab/sqlmodel-toolkit/commits/0.1.1

0.1.0

12 Apr 22:40

Choose a tag to compare

v0.1.0 - Initial Release

First version of sqlmodel-toolkit, a thin layer on top of
SQLModel that brings a fluent query API to sqlmodels.

What's included

Model base class
A drop-in base class for your SQLModel models. Handles engine management and
exposes instance methods for common operations:

  • create(**kwargs) — create and persist a record in one call
  • save() — persist the current instance
  • update(**kwargs) — update attributes and save
  • reload() — discard unsaved changes and refresh from the database
  • delete() — remove the record

Query builder
A chainable query interface available directly on your model classes. No need
to instantiate anything — just call methods on the class:

User.where(active=True).order_by(name="asc").limit(10).all()
User.not_(role="admin").count()
User.with_("posts").where(User.active == True).all()

Supported methods: where, not_, with_, order_by, limit, offset,
distinct, all, first, one, count, find, find_by.

Engine management
Set the engine once on the base Model class and all subclasses inherit it:

Model.set_engine(create_engine("sqlite:///db.sqlite3"))

Notes

This is an early release - the API may change before 1.0.0. Feedback and
contributions are welcome via issues.