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 an engine to talk to your warehouse. An engine owns one connection pool and the dialect for a backend. Build one with create_engine and register it before running any queries:
from semolina import create_engine, register
engine = create_engine(
"default"
) # reads [connections.default] from .semolina.toml
register("default", engine)
Use Model.query() to start building. Chain .metrics() and .dimensions() to select the fields you want, then call .execute():
query = (
Sales.query()
.metrics(Sales.revenue)
.dimensions(Sales.country)
)
.execute() returns a SemolinaCursor. Use it as a context manager so the pooled connection is released when you are done, and call .fetchall_rows() to get Row objects that support both attribute and dict-style access:
with query.execute() as cursor:
for row in cursor.fetchall_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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file semolina-0.6.0.tar.gz.
File metadata
- Download URL: semolina-0.6.0.tar.gz
- Upload date:
- Size: 51.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
492e6d0fe7d69dca12963fe8ba9392b63297f3746e6279885a3993aea2941207
|
|
| MD5 |
29e1456361fa69812ec7d11263ffe852
|
|
| BLAKE2b-256 |
d6e388d4044934a1300d25eabb594a82690f99cb4324009b229af657f0afd2ac
|
Provenance
The following attestation bundles were made for semolina-0.6.0.tar.gz:
Publisher:
release.yml on anentropic/semolina
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
semolina-0.6.0.tar.gz -
Subject digest:
492e6d0fe7d69dca12963fe8ba9392b63297f3746e6279885a3993aea2941207 - Sigstore transparency entry: 1957466213
- Sigstore integration time:
-
Permalink:
anentropic/semolina@cd1dd1dc95a487ed51cab2b32b0478490ff26ef3 -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/anentropic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cd1dd1dc95a487ed51cab2b32b0478490ff26ef3 -
Trigger Event:
push
-
Statement type:
File details
Details for the file semolina-0.6.0-py3-none-any.whl.
File metadata
- Download URL: semolina-0.6.0-py3-none-any.whl
- Upload date:
- Size: 66.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a98787485f9ce0df89c30a82c543979153c529d242bdc8f341d2cda93586bd1d
|
|
| MD5 |
546b73400a85d4369dc0b793902d713f
|
|
| BLAKE2b-256 |
4df03bbd821fe4b8493d049d9bb0919cb262b6282e8c5816c1e186a3dec3d42a
|
Provenance
The following attestation bundles were made for semolina-0.6.0-py3-none-any.whl:
Publisher:
release.yml on anentropic/semolina
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
semolina-0.6.0-py3-none-any.whl -
Subject digest:
a98787485f9ce0df89c30a82c543979153c529d242bdc8f341d2cda93586bd1d - Sigstore transparency entry: 1957466398
- Sigstore integration time:
-
Permalink:
anentropic/semolina@cd1dd1dc95a487ed51cab2b32b0478490ff26ef3 -
Branch / Tag:
refs/tags/v0.6.0 - Owner: https://github.com/anentropic
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@cd1dd1dc95a487ed51cab2b32b0478490ff26ef3 -
Trigger Event:
push
-
Statement type: