Data format
pybrary stores every book as a single row in a SQLite database named library.db at the repository root. The database is handled by SQLAlchemy and keeps the catalogue in sync automatically whenever the application saves.
Columns
| Column | Type | Description |
|---|---|---|
id | int | Auto-incrementing primary key. |
name | text | Book title. |
author | text | Author of the book. |
genre | text | Genre / category. |
copies_total | int | Total physical copies owned. |
copies_avail | int | Copies currently available to borrow. |
reads | int | Cumulative number of borrows. |
Books are exposed to the application as Python objects; to inspect the raw database use any SQLite client:
sqlite3 library.db "SELECT name, author, genre FROM books;"
Migrating from the legacy CSV format
Older pybrary versions stored the catalogue in a plain library.csv. That format is still supported as an import format: on startup an empty database is seeded from library.csv automatically, or explicitly with:
pybrary --db my-library.db --import-csv my-library.csv
Notes
- Records may be added, edited, borrowed, returned or deleted through the TUI and the changes are written back to
library.dbon save or exit. copies_availis clamped to the range[0, copies_total]when a record is loaded.- The database is portable: copy
library.dbanywhere and every record travels with it.