Databases & Middleware
This category covers relational databases, NoSQL stores, search engines, and message queues.
Relational Databases
SQLite
SQLite is a C-language library that implements a small, fast, self-contained SQL database engine.
Installation
environment.systemPackages = [ pkgs.sqlite ];
Verified Usage
# Create new SQLite database and open it
sqlite3 database.db
# Execute SQL command directly
sqlite3 database.db "CREATE TABLE users (id INTEGER PRIMARY KEY, name TEXT);"
# Insert data
sqlite3 database.db "INSERT INTO users (name) VALUES ('Alice');"
# Query data
sqlite3 database.db "SELECT * FROM users;"
NoSQL & Key-Value Stores
etcd
etcd is a distributed key-value store that provides a reliable way to store data that needs to be accessed by a distributed system.
Installation
environment.systemPackages = [ pkgs.etcd ];
Verified Usage
# Start etcd with specific listen addresses
etcd --listen-peer-urls=http://10.0.2.15:8081 --listen-client-urls=http://10.0.2.15:8080 --advertise-client-urls=http://10.0.2.15:8080
# Put key-value pair
etcdctl --endpoints=localhost:8080 put key1 value1
# Get value by key
etcdctl --endpoints=localhost:8080 get key1
# Delete key
etcdctl --endpoints=localhost:8080 del key1
Redis
Redis is an in-memory data structure store used as a database, cache, and message broker.
Installation
environment.systemPackages = [ pkgs.redis ];
Verified Usage
# Start Redis server with specific configuration
redis-server --bind 10.0.2.15 --port 6379 --protected-mode no --daemonize yes
# Connect to Redis server on specific host and port
redis-cli -h hostname -p 6379
# Set key-value pair
redis-cli SET mykey "Hello World"
# Get value by key
redis-cli GET mykey
# Delete key
redis-cli DEL mykey
Valkey
Valkey is a high-performance key-value datastore, forked from Redis.
Installation
environment.systemPackages = [ pkgs.valkey ];
Verified Usage
# Start Valkey server with specific configuration
valkey-server --bind 10.0.2.15 --port 6379 --protected-mode no --daemonize yes
# Connect to Valkey server on specific host and port
valkey-cli -h hostname -p 6379
# Set key-value pair
valkey-cli set mykey "Hello World"
# Get value by key
valkey-cli get mykey
# Delete key
valkey-cli del mykey
Time Series Databases
InfluxDB
InfluxDB is a time series database designed for high write and query loads.
Installation
environment.systemPackages = [ pkgs.influxdb ];
Verified Usage
# Start with specific configuration file
influxd -config /etc/influxdb/influxdb.conf
# Connect to remote InfluxDB server
influx -host hostname -port 8086
# Create database
influx -execute "CREATE DATABASE mydb"
# Use database
influx -execute "USE mydb"
# Write data (InfluxDB line protocol)
influx -execute "INSERT cpu,host=server1 value=0.64"
influx -execute "INSERT memory,host=server1 used=80,total=100"
# Query data
influx -execute "SELECT * FROM cpu"
influx -execute "SELECT * FROM memory WHERE host='server1'"