Nodes/GALIAIS-Nodes/GALIAIS-Nodes Danbooru Runtime DB Builder
ComfyUI Node

GALIAIS-Nodes Danbooru Runtime DB Builder

Turn Your Gigabyte Tag Dump Into a Fast Working Database — Run Once, Not Per Queue

By GALIAIS·Created 3 months ago·Updated 3 months ago· 0
GALIAIS-Nodes Danbooru Runtime DB Builder
    • 运行库DB路径
    • 源DB路径
    • 构建状态JSON
    • 已构建
    源DB路径
    输出DB路径
    执行构建false
    覆盖已有false
    复制模板true
    启用FTS搜索true
    每分类缓存Tag数1000

    The Danbooru tag database is enormous, and searching it raw on every queue run is a great way to turn a fast workflow into a coffee break. The Runtime DB Builder is the pack's answer: it compiles your full dictionary into a compact "runtime DB" - a sibling .runtime.db file purpose-built for fast tag lookup - so the rest of the pack never has to touch the slow original.

    This is step one in the pack's own recommended flow, and it's a "run once after the dictionary changes" node, not a "leave in your graph and run every time" node. The name is the whole pitch: build the runtime DB, then let the DB Loader find it automatically.

    How it works

    Give it a 源DB路径 (source DB path) - your full dictionary file. It reads the danbooru_tags, danbooru_tag_localizations, and tag_taxonomy tables and writes a new database to 输出DB路径; leave that empty and it defaults to <yourdict>.runtime.db right next to the source. Internally it tunes sqlite for a bulk write (journal off, synchronous off, big cache) and, with 启用FTS搜索 on (it is by default), creates an FTS5 virtual table so the "smart" fuzzy searches actually have an index to lean on.

    The inputs that matter:

    • 执行构建 (execute build) - the gate, off by default. Nothing builds until you flip it on and run. This is deliberate: it stops you from accidentally rebuilding a multi-minute database every time you queue.
    • 覆盖已有 (overwrite) - off by default. If the output DB already exists and this is off, the node refuses to rebuild.
    • 复制模板 - carry the dictionary's prompt templates into the runtime DB (on by default; if you don't use dictionary templates you can skip them).
    • 每分类缓存Tag数 - how many tags per category to preload for the lazy selectors; 1000 is a sane default.

    Outputs: 运行库DB路径 (where it wrote), 源DB路径, 构建状态JSON (includes the error message if the build failed - read this, it's the debugging tool), and 已构建 (boolean, the signal that it succeeded).

    Installing it

    It ships in the GALIAIS-Nodes pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/GALIAIS/GALIAIS-Nodes.git
    

    Restart ComfyUI, or use ComfyUI Manager ("GALIAIS-Nodes"). No Python dependencies beyond the standard library - the pack imports sqlite3 and runs. The input file is on you: get the dictionary from the separate GALIAIS/Danbooru-Tag-Database repo.

    Where people get burned

    Three things trip people up. First, forgetting 执行构建 defaults to off - the node runs, returns "not executed," and they wonder why nothing happened. Flip it on. Second, the output path collision: if a .runtime.db already exists from an older dictionary, the loader will keep finding the stale one until you either overwrite it or clear the DB Cache Control caches. Third, a source file that isn't the expected schema - the builder errors out with a message in 构建状态JSON, so check that output before assuming the dictionary is fine. Build once after a dictionary update, and the whole pack gets fast and consistent.

    CategoryGALIAIS-Nodes/config

    Inputs (7)

    NameTypeDefaultDescription
    源DB路径STRING
    输出DB路径STRING
    执行构建BOOLEANfalse
    覆盖已有BOOLEANfalse
    复制模板BOOLEANtrue
    启用FTS搜索BOOLEANtrue
    每分类缓存Tag数INT10000–10000

    Outputs (4)

    NameTypeDescription
    运行库DB路径STRING
    源DB路径STRING
    构建状态JSONSTRING
    已构建BOOLEAN