CLI¶
Installing the package adds a once command (python -m once works too) for looking at and cleaning up the database.
once ls # most recent first: key, status, updated_at, error
once ls --status unknown # repeat --status to show several
once ls --limit 20
once show 3f9a # one record as JSON; a unique key prefix is enough
once reset 3f9a # delete it so the next call runs again
once gc --expired # delete done records whose ttl has passed
once gc --older-than 7d # delete done records not updated for 7 days
once gc --older-than 30d --status failed --status done
once gc --older-than 30d --status all
Options¶
Every command takes:
--db: a SQLite file or apostgresql://URL. Defaults to$ONCE_DB, elseonce.db.--table: the Postgres table. Defaults to$ONCE_TABLE, elseonce_effects. Ignored for SQLite.
The CLI never creates anything. A missing SQLite file or Postgres table is an error (exit code 1).
gc¶
gc needs --older-than, --expired, or both.
--older-than AGEdeletes records not updated for that long. AGE is seconds (90) or a number withs,m,h,dorw(30s,15m,12h,7d,2w).--statuspicks which statuses--older-thandeletes. It defaults todoneand can be repeated;allmeans every status.--expireddeletes done records past their ttl. See Expiry and gc.
Deleting pending or unknown records lets those calls run again, so pick statuses on purpose.
show and reset match a unique key prefix, and fail if the prefix matches no key or more than one.