Skip to main content

microcosm-sqlite

Opinionated data loading with SQLite.

While most distributed application runtimes will use a networked data store for mutable state, the usage patterns of data that is read-only at runtime are great fit for SQLite.

In particular, microcosm-sqlite assumes that applications will

  • Build data sets in advance and ship them as static artifacts (e.g. in source control)
  • Load data immutable sets at runtime without loading entire data sets into memory

Writing Models

Persistent data is expected to use SQLAlchemy's declarative base classes. Because different data sets may be shipped in different SQLite databases, each declarative base class needs to have a unique name and a separate engine configuration, which is achieved by adding DataSet as the base of the declarative base class:

Base = DataSet.create("some_name")


class SomeModel(Base):
    __tablename__ = "sometable"

    id = Column(Integer, primary_key=True)

Using Stores

Basic persistence operations are abstracted through a store:

class SomeStore(Store):

    @property
    def model_class(self):
        return SomeModel


 store = SomeStore()
 results = store.search()

Configuring SQLite

Each DataSet defaults to using :memory: storage, but can be customized in two ways:

  1. The SQLiteBindFactory can be configured with custom paths:

    loader = load_from_dict(
        sqlite=dict(
            paths={
                "some_name": "/path/to/database",
            },
        ),
    )
    graph = create_object_graph("example", loader=loader)
    
  2. The microcosm.sqlite entrypoint can contain a mapping from a data set name to a function that returns a path.

Metadata

Release files for microcosm-sqlite 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for microcosm-sqlite 2.0.0
File Interpreter ABI Platform Actions
microcosm_sqlite-2.0.0-py3-none-any.whl Python 3 none any Details for microcosm_sqlite-2.0.0-py3-none-any.whl

Release files / microcosm_sqlite-2.0.0-py3-none-any.whl

Download URL microcosm_sqlite-2.0.0-py3-none-any.whl
Size 22.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c24013278555c906d275e05bd43ef2ca759b639f64423f135b38cb58adfc6341
BLAKE2b-256 checksum
How to use checksums
09e812cf5ae0dea41c045021243a5b34cc19c79ceceed69cdea7893e8c710958
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.9

Security for microcosm-sqlite 2.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

2.0.0 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page