Skip to content

CA Biositing Data Models

SQLModel-based database models for the CA Biositing project — a research platform for biomass feedstock siting in California.

This package provides 91 ORM models across 15 domain areas (resources, sampling, analysis, infrastructure, external datasets), 7 materialized analytical views, and Alembic-managed migrations backed by PostgreSQL with PostGIS.

Installation

pip install ca-biositing-datamodels

Quick Start

from sqlmodel import Session, select
from ca_biositing.datamodels.database import get_engine
from ca_biositing.datamodels.models import Resource, FieldSample, Place

engine = get_engine()

with Session(engine) as session:
    resources = session.exec(select(Resource)).all()

Development Workflow

This project uses a dual-track migration system:

  1. Table Changes: Modify SQLModel classes and run pixi run migrate-autogenerate -m "message".
  2. Materialized View Fixes: Modify view expressions in data_portal_views/ and run pixi run compile-mv-fixes -m "message".

To iterate on a view fix migration without creating new revisions:

pixi run compile-mv-fixes --revision 0009 --force

Key Dependencies

Contributors

Contributors

Acknowledgement

We acknowledge software engineering support from the University of Washington Scientific Software Engineering Center (SSEC), as part of the Schmidt Sciences Virtual Institute for Scientific Software (VISS).

License

CA Biositing Data Models is licensed under the open source BSD 3-Clause License.