Skip to content

emmanuelrosa/quickdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

quickdb

quickdb is a suite of Nix packages to easily start development instances of PostgreSQL, MariaDB, or CouchDB on GNU Linux.

Features

  • No root needed - You need the Nix package manager to use quickdb, but if you don't already have it you can use the portable version Nix portable.
  • No additional dependencies - You don't need anything other than the Nix package manager.
  • Configured for development - The database is automatically configured to only listen on localhost, and (except for couchdb) you can just log right in without credentials.
  • Multi-instance - You can easily set up multiple instances of a given database; Just edit the config files to use different ports.
  • Runs like a normal process - Stdout goes to the console, and a simple CTRL-C stops the database. No weird daemons to deal with.
  • Multiple database major versions available - Using Nixpkgs snapshots as needed, this repo provides easy access to PostgreSQL 17, 18..., MariaDB 11.4, 11.8...

Demo

asciicast

Note: In the demo I used localhost when connecting with psql. It's also possible to use a socket directory, which is the run directory within the database directory. ex psql -h $PWD/testdb/run DBNAME. However, psql doesn't seem to like relative paths, hence the $PWD.

Use cases

  • Development - I developed quickdb in order to quickly and easily set up a database when I need it without having to have the database running 24/7. You can start a database the moment you need it, and shut it down the moment you're done. No root. No sudo.
  • Staging/testing - When your done with the database, just delete the directory.
  • Database migration tests - Want to see what happens when upgrading PostgreSQL from 17 to 18? Just make a copy your database directory, and run it with the new version. No sudo needed.

Packages

To get a list of the available packages, run nix flake show github:emmanuelrosa/quickdb

Usage

Each package has three modes of operation:

  1. Initialization - When executed with a path to a non-existent directory, the directory is created and the database system is initialized within the directory. After initialization, the database system can be configured by editing one or more configuration files.
  2. Execution - When executed with a path to an existent directory, it is assumed a database has been initialized within the directory, so the database is started in the foreground. This means standard output is printed to the screen, and a simple CTRL-C is all that's needed to stop the database.
  3. Shell - When executed without any arguments, a BASH shell is started with the database client tools in the PATH.

Examples

PostgreSQL

  1. To create a PostgreSQL database, execute: nix run github:emmanuelrosa/quickdb#quickdb-postgresql-17 -- ~/my-postgresql
  2. To configure the database, edit the *.conf files in ~/my-postgresql.
  3. To run the database, execute the same command: nix run github:emmanuelrosa/quickdb#quickdb-postgresql-17 -- ~/my-postgresql
  4. To access the postgresql client tools, using another terminal execute nix run github:emmanuelrosa/quickdb#quickdb-postgresql-17
  5. To stop postgresql, press CTRL-C.

MariaDB

  1. To create a MariaDB database, execute: nix run github:emmanuelrosa/quickdb#quickdb-mariadb-114 -- ~/my-mariadb
  2. To configure the database, edit ~/my-mariadb/etc/my.cnf.
  3. To run the database, execute the same command: nix run github:emmanuelrosa/quickdb#quickdb-mariadb-114 -- ~/my-mariadb
  4. To access the mariadb client tools, using another terminal execute nix run github:emmanuelrosa/quickdb#quickdb-mariadb-114. Before using the mariadb client, set the envirionment variable MYSQL_UNIX_PORT to the path to the socket file; ex. export MYSQL_UNIX_PORT=~/my-mariadb/run/mariadb.sock
  5. To stop mariadb, press CTRL-C.

CouchDB

  1. To create a CouchDB database, execute: nix run github:emmanuelrosa/quickdb#quickdb-couchdb-3 -- ~/my-couchdb
  2. To configure the database, edit ~/my-couchdb/etc/local.ini and ~/my-couchdb/etc/epmd.env. The default user name is admin and the password is password.
  3. To run the database, execute the same command: nix run github:emmanuelrosa/quickdb#quickdb-couchdb-3 -- ~/my-couchdb
  4. To use curl and jq with couchdb, from another terminal execute nix run github:emmanuelrosa/quickdb#quickdb-couchdb-3
  5. To stop couchdb, press CTRL-C.

About

Run rootless and portable way to run databases for development and demos.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages