sok.server.db
The database of S.O.K Server: sok.db, a SQLite file next to config.json.
The schema grows by steps (MIGRATIONS); PRAGMA user_version says how many are applied, so an older database is brought up to date when it opens.
Database
class Database(path: Path)The SQLite file, shared by the requests of the server.
Parameters
| Name | Type | Description |
|---|---|---|
path | Path |
Attributes
| Name |
|---|
created |
path |
versionproperty
int
The number of migrations applied.
close
def close() -> None:transaction
def transaction() -> Iterator[sqlite3.Connection]:Run the statements of the block together: all of them, or none.
SourceAttributes
| Name | Type | Value |
|---|---|---|
MIGRATIONS | List[str] | ['\n CREATE TABLE account (\n id INTEGER PRIMARY KEY CHECK (id = 1),\n username TEXT NOT NULL,\n password_hash TEXT NOT NULL,\n created TEXT NOT NULL\n );\n CREATE TABLE sessions (\n token_hash TEXT PRIMARY KEY,\n created TEXT NOT NULL,\n expires TEXT NOT NULL\n );\n ', '\n CREATE TABLE folders (\n role TEXT NOT NULL,\n position INTEGER NOT NULL,\n path TEXT NOT NULL,\n PRIMARY KEY (role, position)\n );\n ', "\n CREATE TABLE scans (\n id INTEGER PRIMARY KEY,\n started TEXT NOT NULL,\n finished TEXT,\n status TEXT NOT NULL,\n error TEXT,\n missing_sources TEXT NOT NULL DEFAULT '[]'\n );\n CREATE TABLE rows (\n id INTEGER PRIMARY KEY,\n key TEXT NOT NULL UNIQUE,\n media_type TEXT NOT NULL,\n kind TEXT NOT NULL,\n title TEXT,\n files TEXT NOT NULL,\n query TEXT,\n year INTEGER,\n candidates TEXT NOT NULL DEFAULT '[]',\n selected INTEGER,\n status TEXT NOT NULL,\n destination INTEGER NOT NULL DEFAULT 0,\n details TEXT\n );\n CREATE INDEX rows_media_type ON rows (media_type);\n CREATE TABLE to_check (\n path TEXT PRIMARY KEY,\n kind TEXT NOT NULL,\n title TEXT,\n reason TEXT NOT NULL\n );\n CREATE TABLE type_choices (\n path TEXT PRIMARY KEY,\n kind TEXT NOT NULL\n );\n ", '\n ALTER TABLE rows ADD COLUMN errors TEXT;\n CREATE TABLE renames (\n id INTEGER PRIMARY KEY,\n media_type TEXT NOT NULL,\n started TEXT NOT NULL,\n finished TEXT,\n status TEXT NOT NULL,\n error TEXT,\n result TEXT\n );\n CREATE TABLE history (\n id TEXT PRIMARY KEY,\n position INTEGER NOT NULL,\n date TEXT NOT NULL,\n kind TEXT NOT NULL,\n media_type TEXT NOT NULL,\n operation TEXT NOT NULL\n );\n ', '\n ALTER TABLE scans ADD COLUMN processed INTEGER NOT NULL DEFAULT 0;\n CREATE TABLE processed (\n path TEXT PRIMARY KEY,\n size INTEGER NOT NULL,\n mtime_ns INTEGER NOT NULL,\n target TEXT NOT NULL,\n operation_id TEXT NOT NULL,\n date TEXT NOT NULL\n );\n ', '\n ALTER TABLE scans ADD COLUMN auto INTEGER NOT NULL DEFAULT 0;\n ALTER TABLE renames ADD COLUMN auto INTEGER NOT NULL DEFAULT 0;\n CREATE TABLE options (\n key TEXT PRIMARY KEY,\n value TEXT NOT NULL\n );\n '] |