Generic toolkit for building 3-tier applications.
  • Python 96.4%
  • Dockerfile 2.2%
  • Mako 1.4%
Find a file
2026-09-10 19:04:38 +00:00
.devcontainer adding missing binaries to dockerfile 2026-09-04 00:50:20 +00:00
.vscode fixing warnings 2026-09-04 12:35:45 +00:00
py3tier adding migration handling on init 2026-09-10 19:04:38 +00:00
table_definitions adding alembic migrations 2026-09-04 02:07:17 +00:00
.gitignore adding user table definitions folder to loading 2026-09-04 02:37:01 +00:00
alembic.ini removing hard coded db path 2026-09-04 10:12:32 +00:00
pyproject.toml adding alembic migrations 2026-09-04 02:07:17 +00:00
README.md adding operations module and some refactoring 2026-09-04 10:07:13 +00:00
uv.lock adding alembic migrations 2026-09-04 02:07:17 +00:00

py3tier

Generic toolkit for building 3-tier applications.

YAML table definitions

Tables can be generated from a small YAML definition containing a class name, an optional table name, and fields aligned with sqlmodel.Field options:

name: User
table: users
fields:
	display_name:
		type: str
		max_length: 100
		nullable: false

An integer id primary key is added automatically and is generated when a row is inserted. Each row also receives a generated UUID uid; the same value is available in the corresponding history row.

from py3tier.application.data_models import load_table_class

User, UserHistory = load_table_class("user.yaml")

UserHistory contains nullable snapshots of all User columns, an automatic hid primary key, event_on, operation, audit_uid, revision, and sha256_all and sha256_data snapshot hashes. revision defaults to 0 for the initial snapshot; the persistence layer should increment it for later snapshots of the same row.

Supported field types are bool, date, datetime, decimal, float, int, str, time, and uuid. Relations and foreign keys are not part of this format yet.

Database migrations

Alembic loads application-owned YAML definitions from py3tier/table_definitions/ and user-owned definitions from the top-level table_definitions/ before generating migrations, including each table's history table. The default database is sqlite:///./py3tier.db; set PY3TIER_DATABASE_URL to override it. The user definition folder can be changed with USER_TCLASS_DEFINITIONS_DIR.

uv run alembic revision --autogenerate -m "create tables"
uv run alembic upgrade head