microcosm-sqlite


Namemicrocosm-sqlite JSON
Version 2.0.0 PyPI version JSON
download
home_pagehttps://github.com/globality-corp/microcosm-sqlite
SummaryOpinionated persistence with SQLite
upload_time2024-06-28 21:25:03
maintainerNone
docs_urlNone
authorGlobality Engineering
requires_python>=3.11
licenseNone
keywords microcosm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/globality-corp/microcosm-sqlite",
    "name": "microcosm-sqlite",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.11",
    "maintainer_email": null,
    "keywords": "microcosm",
    "author": "Globality Engineering",
    "author_email": "engineering@globality.com",
    "download_url": null,
    "platform": null,
    "description": "# microcosm-sqlite\n\nOpinionated data loading with SQLite.\n\nWhile most distributed application runtimes will use a networked data store for mutable state,\nthe usage patterns of data that is read-only at runtime are great fit for SQLite.\n\nIn particular, `microcosm-sqlite` assumes that applications will\n\n -  Build data sets in advance and ship them as static artifacts (e.g. in source control)\n -  Load data immutable sets at runtime without loading entire data sets into memory\n\n\n## Writing Models\n\nPersistent data is expected to use SQLAlchemy's declarative base classes. Because different data sets\nmay be shipped in different SQLite databases, each declarative base class needs to have a **unique**\nname and a separate engine configuration, which is achieved by adding `DataSet` as the base of the\ndeclarative base class:\n\n    Base = DataSet.create(\"some_name\")\n\n\n    class SomeModel(Base):\n        __tablename__ = \"sometable\"\n\n        id = Column(Integer, primary_key=True)\n\n\n## Using Stores\n\nBasic persistence operations are abstracted through a store:\n\n    class SomeStore(Store):\n\n        @property\n        def model_class(self):\n            return SomeModel\n\n\n     store = SomeStore()\n     results = store.search()\n\n\n## Configuring SQLite\n\nEach `DataSet` defaults to using `:memory:` storage, but can be customized in two ways:\n\n 1. The `SQLiteBindFactory` can be configured with custom paths:\n\n        loader = load_from_dict(\n            sqlite=dict(\n                paths={\n                    \"some_name\": \"/path/to/database\",\n                },\n            ),\n        )\n        graph = create_object_graph(\"example\", loader=loader)\n\n 2. The `microcosm.sqlite` entrypoint can contain a mapping from a data set name to a\n    function that returns a path.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Opinionated persistence with SQLite",
    "version": "2.0.0",
    "project_urls": {
        "Homepage": "https://github.com/globality-corp/microcosm-sqlite"
    },
    "split_keywords": [
        "microcosm"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "09e812cf5ae0dea41c045021243a5b34cc19c79ceceed69cdea7893e8c710958",
                "md5": "9c202492830eaec672c75449b803c60f",
                "sha256": "c24013278555c906d275e05bd43ef2ca759b639f64423f135b38cb58adfc6341"
            },
            "downloads": -1,
            "filename": "microcosm_sqlite-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9c202492830eaec672c75449b803c60f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11",
            "size": 22182,
            "upload_time": "2024-06-28T21:25:03",
            "upload_time_iso_8601": "2024-06-28T21:25:03.980826Z",
            "url": "https://files.pythonhosted.org/packages/09/e8/12cf5ae0dea41c045021243a5b34cc19c79ceceed69cdea7893e8c710958/microcosm_sqlite-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-28 21:25:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "globality-corp",
    "github_project": "microcosm-sqlite",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "microcosm-sqlite"
}
        
Elapsed time: 4.33473s