The Twelve-Factor App conventions now followed by many web developers recommend that web applications gets their configuration from environment variables. Database connection parameters are usually given all in one environment variable in the form of a URL. This variable is normally called DATABASE_URL. This module provides procedures to translate database URLs into a form that Racket’s db module can use.
MySQL, PostgreSQL and SQLite URLs are currently supported.
The procedure returns two values: a hash table of keyword arguments suitable for a database connect procedure from the db libray; and the right connect procedure to use.
> (database-url-parse "mysql://user:[email protected]/dbname") '#hash((#:database . "dbname") (#:password . "pass") (#:server . "localhost") (#:user . "user")) |#<procedure:mysql-connect>|
Most people will probably want to skip database-url-parse and use this procedure directly.