explaingit

lllyasviel/singlefiledb

Analysis updated 2026-07-09 · repo last pushed 2023-11-24

85PythonAudience · developerComplexity · 2/5DormantSetup · easy

TLDR

A zero-dependency Python key-value store in a single file that saves data as readable JSON, designed for managing millions of records without a database server.

Mindmap

mindmap
  root((repo))
    What it does
      Key-value storage
      Saves to disk
      Batched writes
    Tech stack
      Python
      SQLite
      JSON
    Use cases
      ML metadata
      Web scraping data
      Experiment tracking
    Audience
      Solo developers
      Researchers
      Startup founders
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

Store millions of machine learning image metadata records like Stable Diffusion prompts.

USE CASE 2

Save web scraping results to disk without setting up a database server.

USE CASE 3

Track experiment results in a Python research project with automatic crash recovery.

USE CASE 4

Process massive datasets one record at a time using minimal memory.

What is it built with?

PythonSQLiteJSON

How does it compare?

lllyasviel/singlefiledbmichaelliao/miniweiboaqua5230/usage
Stars858382
LanguagePythonPythonPython
Last pushed2023-11-242012-12-28
MaintenanceDormantDormant
Setup difficultyeasymoderateeasy
Complexity2/53/52/5
Audiencedeveloperdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · easy Time to first run · 5min

No installation needed beyond copying the single Python file into your project.

The license for this repository is not specified in the provided information, so check the repository files for terms before use.

In plain English

Single File Database (SFDB) is a lightweight Python tool for storing key-value data, think of it like a dictionary that saves to disk. The author created it to manage millions of image metadata records in machine learning projects, particularly for storing Stable Diffusion prompts. The entire thing is one Python file with under 150 lines of code, no external dependencies, and you install it by just copying the file into your project. Under the hood, it stores data using SQLite, a widely-supported database format. Your values are saved as human-readable JSON text, which means you can open the database file in any SQLite viewer and inspect or edit your data directly, even outside your code. For small datasets, you can load everything into memory with a single line. For massive datasets, it lets you read and write items one at a time without loading the whole file, so you could theoretically process 10TB of data using only 10MB of memory. This would appeal to someone building a Python app who needs persistent storage but doesn't want the overhead of setting up a full database server or learning a complex ORM. A solo developer prototyping an AI tool, a researcher tracking experiment results, or a startup founder scraping and storing web data could drop this in and start saving records immediately. The thread-safety and automatic crash recovery mean you don't have to worry much about data corruption if your app dies mid-write. A notable design choice is how it handles disk writes. Updates appear instant to your code, but the actual file writes are batched, either every 16,384 updates, every 60 seconds, or when the program exits. This reduces wear on your storage drive and improves performance, though it means a sudden power loss could lose up to a minute of recent changes (application crashes, however, are handled safely by SQLite's built-in recovery).

Copy-paste prompts

Prompt 1
I have a Python script that scrapes data and stores it in a regular dictionary that gets lost when the script ends. Show me how to use singlefiledb so my data persists to disk automatically.
Prompt 2
I am building a Stable Diffusion project and need to store millions of image prompt records. How do I use singlefiledb to write and read these records efficiently without running out of memory?
Prompt 3
Show me how to open a singlefiledb database file and inspect the saved JSON data using a standard SQLite viewer or the sqlite3 command line tool.
Prompt 4
I need to process a 500GB dataset in Python but only have 8GB of RAM. How can I use singlefiledb to read and write records one at a time without loading the whole dataset into memory?

Frequently asked questions

What is singlefiledb?

A zero-dependency Python key-value store in a single file that saves data as readable JSON, designed for managing millions of records without a database server.

What language is singlefiledb written in?

Mainly Python. The stack also includes Python, SQLite, JSON.

Is singlefiledb actively maintained?

Dormant — no commits in 2+ years (last push 2023-11-24).

What license does singlefiledb use?

The license for this repository is not specified in the provided information, so check the repository files for terms before use.

How hard is singlefiledb to set up?

Setup difficulty is rated easy, with roughly 5min to a first successful run.

Who is singlefiledb for?

Mainly developer.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Verify against the repo before relying on details.