Skip to main content

Common tool for forging and maintaining sqlite databases

Project description

SQLite Forge

SQLite Forge is a lightweight toolkit that helps you declare and maintain SQLite tables from Python. Define your schema once, then manage tables, run queries, ingest pandas DataFrame objects, and export results.

Highlights

  • Declarative table definitions with schemas and optional multi-column primary keys
  • Safe helpers to create/drop tables and check existence
  • DataFrame ingestion with optional incremental overwrite support
  • Query execution that returns pandas DataFrame objects
  • Table export helpers for csv, json, and parquet

Installation

pip install sqlite-forge

For development:

git clone https://github.com/Tom3man/sqlite-forge.git
cd sqlite-forge
poetry install --with dev --with docs

Quick Start

from pathlib import Path

import pandas as pd

from sqlite_forge import SqliteDatabase


class ExampleTable(SqliteDatabase):
    DEFAULT_PATH = "example_table"
    PRIMARY_KEY = ("id",)
    DEFAULT_SCHEMA = {
        "id": "INTEGER",
        "name": "TEXT",
        "score": "REAL",
    }


db = ExampleTable(database_path=Path("./data"))
db.create_table(overwrite=True)

db.ingest_dataframe(
    pd.DataFrame(
        [
            {"id": 1, "name": "Alice", "score": 9.2},
            {"id": 2, "name": "Bob", "score": 8.7},
        ]
    )
)

print(db.fetch_table())
db.export_table("./data/example_table.csv", format="csv")

Development

poetry run pytest
poetry run ruff check .
poetry run mypy
poetry build

Documentation

poetry run mkdocs serve

Release

  1. Bump version in pyproject.toml.
  2. Update CHANGELOG.md.
  3. Publish:
poetry publish --build

Changelog

See CHANGELOG.md.

Licence

MIT. See LICENSE.

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

sqlite_forge-1.1.1.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

sqlite_forge-1.1.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file sqlite_forge-1.1.1.tar.gz.

File metadata

  • Download URL: sqlite_forge-1.1.1.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.17.0-14-generic

File hashes

Hashes for sqlite_forge-1.1.1.tar.gz
Algorithm Hash digest
SHA256 51bce9ef6663c89e19a117c746eff61af1b9a538b73107395f8a5af9515bde51
MD5 6c24fce5d636a159617a824a47c81e6f
BLAKE2b-256 423563a1488e51b0cd9a6b603931e77da8e78f1be801ca9e330d726d081b5efa

See more details on using hashes here.

File details

Details for the file sqlite_forge-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: sqlite_forge-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.17.0-14-generic

File hashes

Hashes for sqlite_forge-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bb779e6b5483a7b19fa8456853231f9deade9000b11349c2ab418d61dce883ac
MD5 7a157994fc396e5ba5ec3279aea22024
BLAKE2b-256 ced1c1326570d38b030e36292269dfc14c1a8e4f034cd8fca334d0814d23b36a

See more details on using hashes here.

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