Skip to content

A tiny Python CLI that reads Logseq's DB graph, decodes the Transit data inside, and prints any page as a plain-text outline.

Notifications You must be signed in to change notification settings

erinc/logseq-page-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 

Repository files navigation

Logseq Page CLI

A tiny Python CLI that reads Logseq's SQLite graph (db.sqlite), decodes the Transit data inside, and prints any page (regular or journal) as a plain-text outline. It also resolves raw UUID links ([[692cf4c0-…]]) to their human-friendly titles.

Features

  • Works with the current Logseq db.sqlite format (Transit-encoded datoms stored in the kvs table).
  • Accepts either a page name (Travels, Library, Peru) or a journal date (2025-12-03).
  • Defaults to today's journal page when no argument is passed.
  • Replaces UUID-based links with the referenced block/page title for easier reading.

Requirements

  • Python 3.11+ (any version supported by transit-python).
  • transit-python==0.8.302 (already declared in requirements.txt).
  • Logseq graph folder containing db.sqlite, db.sqlite-shm, and db.sqlite-wal (copy/symlink the SQLite files next to the CLI).

Setup

# create / reuse a virtualenv with uv (recommended)
uv venv
source .venv/bin/activate
uv pip install -r requirements.txt

If you prefer vanilla pip:

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt

Usage

# default: today's journal page
uv run logseq_page_cli.py

# specific journal date
uv run logseq_page_cli.py 2025-12-03

# regular page or tag
uv run logseq_page_cli.py Travels
uv run logseq_page_cli.py "Library"

The script prints a header such as Journal page: 2025-12-03 [entity 16815] followed by an indented list of blocks. If the entire page is empty, you’ll see (no blocks recorded for this page).

Notes

  • The CLI is read-only; it never writes to the database.
  • Because Logseq stores every “fact” as a datom, the script rebuilds all entities in memory. For very large graphs this can take a few seconds.
  • If you add new notes and do not see them in the output, ensure Logseq has synced changes to db.sqlite (e.g., by closing Logseq or forcing a save).
  • This script is created by Codex CLI.

License

MIT. Do whatever makes your graph happier.

About

A tiny Python CLI that reads Logseq's DB graph, decodes the Transit data inside, and prints any page as a plain-text outline.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages