Skip to main content

A Pythonic ORM for querying data warehouse semantic views (Snowflake, Databricks, DuckDB)

Project description

Semolina

[ Docs ]

The ORM for your Semantic Layer.

Typed models in Python, supporting IDE autocomplete, and a Django-like fluent query interface for the semantic layer of your data warehouse backend.

pip install semolina
pip install semolina[snowflake]
pip install semolina[databricks]

A model maps to a semantic view in your warehouse.

from semolina import (
    SemanticView,
    Metric,
    Dimension,
)


class Sales(SemanticView, view="sales"):
    revenue = Metric()
    cost = Metric()
    country = Dimension()
    region = Dimension()

Semolina needs a connection pool to talk to your warehouse. Register one before running any queries:

from semolina import register, pool_from_config

pool, dialect = pool_from_config()  # reads .semolina.toml
register("default", pool, dialect=dialect)

Use Model.query() to start building. Chain .metrics() and .dimensions() to select the fields you want, then call .execute():

cursor = (
    Sales.query()
    .metrics(Sales.revenue)
    .dimensions(Sales.country)
    .execute()
)

.execute() returns a SemolinaCursor. Call .fetchall_rows() to get Row objects that support both attribute and dict-style access:

rows = cursor.fetchall_rows()
for row in rows:
    print(row.country, row.revenue)  # attribute access
    print(row["country"])  # dict-style access

You should see output like:

US 1000
US
CA 2000
CA
US 500
US

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

semolina-0.4.0.tar.gz (51.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

semolina-0.4.0-py3-none-any.whl (67.0 kB view details)

Uploaded Python 3

File details

Details for the file semolina-0.4.0.tar.gz.

File metadata

  • Download URL: semolina-0.4.0.tar.gz
  • Upload date:
  • Size: 51.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for semolina-0.4.0.tar.gz
Algorithm Hash digest
SHA256 e3073589694ad9e7ecc6c5925b705efb4276b0fbd9b468d99f12ef1a9027a006
MD5 e9467c0369cd050ff484bc0da7d341b8
BLAKE2b-256 2d38088899bfbcd8f4004abd322a4436ad1e631cd3bd448a277a2838575b92e9

See more details on using hashes here.

Provenance

The following attestation bundles were made for semolina-0.4.0.tar.gz:

Publisher: release.yml on anentropic/semolina

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file semolina-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: semolina-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 67.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for semolina-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5b9b7fb40df096ca7cd5b58555a2554421662eb426f56f979ce41ef2f7aeb88
MD5 b9bc0cbaea7a9cb331fef6ae72395b8f
BLAKE2b-256 20117d592675fd350e96541b91727c7da9b07d8c125b1d6305c4db3da9a42171

See more details on using hashes here.

Provenance

The following attestation bundles were made for semolina-0.4.0-py3-none-any.whl:

Publisher: release.yml on anentropic/semolina

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page