Skip to main content
https://github.com/MacHu-GWU/dataclasses_sqlitedict-project/workflows/CI/badge.svg https://codecov.io/gh/MacHu-GWU/dataclasses_sqlitedict-project/branch/main/graph/badge.svg https://img.shields.io/pypi/v/dataclasses_sqlitedict.svg https://img.shields.io/pypi/l/dataclasses_sqlitedict.svg https://img.shields.io/pypi/pyversions/dataclasses_sqlitedict.svg https://img.shields.io/badge/STAR_Me_on_GitHub!--None.svg?style=social
https://img.shields.io/badge/Link-Source_Code-blue.svg https://img.shields.io/badge/Link-Install-blue.svg https://img.shields.io/badge/Link-GitHub-blue.svg https://img.shields.io/badge/Link-Submit_Issue-blue.svg https://img.shields.io/badge/Link-Request_Feature-blue.svg https://img.shields.io/badge/Link-Download-blue.svg

Welcome to dataclasses_sqlitedict Documentation

Sqlite backed dataclasses. It is a light weight persistent storage for dataclasses. If you are looking for a full featured ORM, please check out SQLAlchemy.

Features

Single Row Data Model

Each instance of class is a row in the table. And all the instances of the same class share the same database table.

import dataclasses
from sqlitedict import SqliteDict
from dataclasses_sqlitedict import SingleRowDataModel

@dataclasses.dataclass
class User(SingleRowDataModel):
    username: str
    password: str

    db = SqliteDict("user.sqlite", autocommit=False)

    @property
    def primary_key(self) -> str:
        return self.username

user = User(username="alice", password="pwd")
user.write()

user1 = User.read("alice")
print(user1)

Single Table Data Model

Each instance of class is a table. Each instance of class could be different tables in the same databases, or different table in different databases.

import dataclasses
from sqlitedict import SqliteDict
from dataclasses_sqlitedict import SingleTableDataModel

@dataclasses.dataclass
class User(SingleTableDataModel):
    username: str
    password: str

db = SqliteDict("user.sqlite", autocommit=False)

user = User(db=db, username="alice", password="pwd")
user.write()

user1 = User.read(db)
print(user1)

Install

dataclasses_sqlitedict is released on PyPI, so all you need is:

$ pip install dataclasses_sqlitedict

To upgrade to latest version:

$ pip install --upgrade dataclasses_sqlitedict

Metadata

Release files for dataclasses-sqlitedict 0.1.1

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

Source distribution (sdist)

Source distribution for dataclasses-sqlitedict 0.1.1
File Size Uploaded
dataclasses_sqlitedict-0.1.1.tar.gz 7.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dataclasses-sqlitedict 0.1.1
File Interpreter ABI Platform
dataclasses_sqlitedict-0.1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

Total release size: 15.2 kB

Release files / dataclasses_sqlitedict-0.1.1.tar.gz

Download URL dataclasses_sqlitedict-0.1.1.tar.gz
Size 7.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a0f479b4c3508a30baa4d314d39bf1dda0f3c36763aba0917e05ee4a02a93557
BLAKE2b-256 checksum
How to use checksums
56c03e9cddb11a874a2c8b3067cf8ce7ca1c8a172a36e38b9c8cd76cab6f3803
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.11

Release files / dataclasses_sqlitedict-0.1.1-py2.py3-none-any.whl

Download URL dataclasses_sqlitedict-0.1.1-py2.py3-none-any.whl
Size 7.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
8241e171b0ed34130593afc43e8cefad52a3be8a86bfd932f0f1f3b941547b39
BLAKE2b-256 checksum
How to use checksums
d2ad93e9c05bb43b496f87eaab5471a4a2d75f6a7fecec62bdd7ff6c10e369d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.8.11

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

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