Skip to content

ReactorScram/sql-hummus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SQL Hummus

A tasty bite of SQLite.

sql-hummus has simple defaults for using SQLite files as timestamped logs or key-value stores.

sql-hummus offers a Rust API and a CLI for shell scripting or interactive use: cargo install sql-hummus

Log files

"Log" files are append-only arrays of text elements. They act like a Rust Vec<(SystemTime, String)>, but append-only and persisted on disk.

# Append a new element to `log.db`, assuming it's a log file or doesn't exist yet
sql-hummus log push log.db "Writing a new element to a file that may exist"

# Append multiple lines from stdin
echo "This will all\nbe one element." | sql-hummus log push log.db

# Read back the elements as JSONL
sql-hummus log iter log.db | jq .

# Get a single entry by its ID
sql-hummus log get log.db 0

# Slice into the log file using a half-open interval
sql-hummus log get log.db 0..2

# Slice into the log using a date interval
sql-hummus log get log.db "2026-07-07 04:31:00+00:00..2026-07-07 04:32:00+00:00"

Every element has the Unix epoch and local time (as RFC 3339) from when it was written.

Use log files for app logging or personal journaling. SQLite offers more reliability than plaintext, and it keeps the timestamps out-of-band.

KV files

"KV" files are key-value stores. They act like a Rust BTreeMap<String, String>.

# Insert an element into `my-settings.db`
sql-hummus kv insert my-settings.db "/myapp/color_mode" "light_mode"

# Upsert the same element
sql-hummus kv insert my-settings.db "/myapp/color_mode" "dark_mode"

# Return the most-recently-inserted value for the given key
sql-hummus kv get my-settings.db "/myapp/color_mode"

# Returns non-zero if the key isn't present
sql-hummus kv contains-key my-settings.db "/myapp/color_mode"

# Insert an empty string to use any KV file as a set
sql-hummus kv insert my-settings.db "/myapp/bookmarks/https://example.com/" ""

# Get a range of elements matching a prefix
sql-hummus kv with-prefix my-settings.db "/myapp/"

# Get all elements
sql-hummus kv with-prefix my-settings.db

KV elements have no metadata.

Use KV files for app settings, bookmark storage, or keeping metadata about file paths. SQLite offers more reliability than plain JSON, and lookups are faster for large files.

fput

fput/github.com/ReactorScram/sql-hummus

Finally, a Windows Registry for GNU/Linux.

About

No description, website, or topics provided.

Resources

License

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages