Skip to content

Database clients ​

Functions of the tools module at v0.7.0. Each returns what a command runs in; import it with import * as tools from "tools".

psql.env ​

psql, pg_dump and the other PostgreSQL clients.

lask
psql.env(
  --image: Environment = #postgres:18.6-alpine3.24,
  --host: String | Null = null,
  --port: String | Null = null,
  --user: String | Null = null,
  --password: String | Null = <secret>,
  --database: String | Null = null,
  --sslmode: String | Null = null,
  --network: String | Null = null,
  --base_access: String | Map<String> | Null = null,
  --with: Array<Record<env: Map<String>, volumes: Array<String>>> = [],
  --extra_env: Map<String> = {}
): Runnable

The image is #postgres:18.6-alpine3.24 unless --image names another; use the major release of the server. lask sync pulls and pins whichever image is used (lask spec 10.3); a run never pulls.

Parameters

  • --image The image to run; another release is passed as image = #postgres:<tag>.
  • --host PGHOST.
  • --port PGPORT.
  • --user PGUSER.
  • --password!! PGPASSWORD; masked in the command log.
  • --database PGDATABASE.
  • --sslmode PGSSLMODE.
  • --network The container's network: a Compose network, or "host".
  • --base_access What the container may do with the project directory: "rw" (the default), "ro", "none", or a table of paths such as {".": "ro", "dist": "rw"} (lask spec 10.2).
  • --with Setups of other tools this environment should also carry.
  • --extra_env Any other variable; below --with and the named parameters.

Returns Runnable: The environment, for command { "psql" } on ... or $[...].

Image postgres:18.6-alpine3.24

bash
lask eval psql.env --host host.docker.internal --user app --database app

lib/psql.lask

psql.setup ​

What libpq and the clients built on it read to reach a PostgreSQL server: psql and pg_dump, psycopg, node-postgres, and most others. Give it to an application's environment through --with.

lask
psql.setup(
  --host: String | Null = null,
  --port: String | Null = null,
  --user: String | Null = null,
  --password: String | Null = <secret>,
  --database: String | Null = null,
  --sslmode: String | Null = null
): Record<env: Map<String>, volumes: Array<String>>

Parameters

  • --host PGHOST.
  • --port PGPORT.
  • --user PGUSER.
  • --password!! PGPASSWORD; masked in the command log.
  • --database PGDATABASE.
  • --sslmode PGSSLMODE, e.g. "require".

Returns Record<env: Map<String>, volumes: Array<String>>: The variables, for a tool's --with.

lib/psql.lask

mysql.env ​

The MySQL client.

lask
mysql.env(
  --image: Environment = #mysql:8.4.11,
  --host: String | Null = null,
  --port: String | Null = null,
  --user: String | Null = null,
  --password: String | Null = <secret>,
  --database: String | Null = null,
  --network: String | Null = null,
  --base_access: String | Map<String> | Null = null,
  --with: Array<Record<env: Map<String>, volumes: Array<String>>> = [],
  --extra_env: Map<String> = {}
): Runnable

The image is #mysql:8.4.11 (an LTS release) unless --image names another. The client reads the host, the port and the password from its environment (MYSQL_HOST, MYSQL_TCP_PORT, MYSQL_PWD), but no user and no database: those go on its command line. They are set as MYSQL_USER and MYSQL_DATABASE for that, mysql -u "$MYSQL_USER" "$MYSQL_DATABASE".

Parameters

  • --image The image to run; another release is passed as image = #mysql:<tag>.
  • --host MYSQL_HOST.
  • --port MYSQL_TCP_PORT.
  • --user MYSQL_USER, for the command line.
  • --password!! MYSQL_PWD; masked in the command log.
  • --database MYSQL_DATABASE, for the command line.
  • --network The container's network: a Compose network, or "host".
  • --base_access What the container may do with the project directory: "rw" (the default), "ro", "none", or a table of paths such as {".": "ro", "dist": "rw"} (lask spec 10.2).
  • --with Setups of other tools this environment should also carry.
  • --extra_env Any other variable; below --with and the named parameters.

Returns Runnable: The environment, for command { "mysql" } on ... or $[...].

Image mysql:8.4.11

bash
lask eval mysql.env --host host.docker.internal --user app

lib/mysql.lask

redis_cli.env ​

redis-cli.

lask
redis_cli.env(
  --image: Environment = #redis:8.10.2-alpine,
  --password: String | Null = <secret>,
  --network: String | Null = null,
  --base_access: String | Map<String> | Null = null,
  --with: Array<Record<env: Map<String>, volumes: Array<String>>> = [],
  --extra_env: Map<String> = {}
): Runnable

The image is #redis:8.10.2-alpine unless --image names another. redis-cli reads its password from the environment (REDISCLI_AUTH) and nothing else: the host goes on its command line, redis-cli -h host.docker.internal.

Parameters

  • --image The image to run; another release is passed as image = #redis:<tag>.
  • --password!! REDISCLI_AUTH; masked in the command log.
  • --network The container's network: a Compose network, or "host".
  • --base_access What the container may do with the project directory: "rw" (the default), "ro", "none", or a table of paths such as {".": "ro", "dist": "rw"} (lask spec 10.2).
  • --with Setups of other tools this environment should also carry.
  • --extra_env Any other variable; below --with and the named parameters.

Returns Runnable: The environment, for command { "redis-cli" } on ... or $[...].

Image redis:8.10.2-alpine

bash
lask eval redis_cli.env

lib/redis_cli.lask

migrate.env ​

golang-migrate.

lask
migrate.env(
  --image: Environment = #migrate/migrate:v4.20.1,
  --database_url: String | Null = <secret>,
  --network: String | Null = null,
  --base_access: String | Map<String> | Null = null,
  --with: Array<Record<env: Map<String>, volumes: Array<String>>> = [],
  --extra_env: Map<String> = {}
): Runnable

The image is #migrate/migrate:v4.20.1 unless --image names another. migrate takes its database on the command line only, so the URL is set as DATABASE_URL for it: migrate -database "$DATABASE_URL" -path db/migrations up. The URL carries the password, and is masked whole.

Parameters

  • --image The image to run; another release is passed as image = #migrate/migrate:<tag>.
  • --database_url!! DATABASE_URL; masked in the command log.
  • --network The container's network: a Compose network, or "host".
  • --base_access What the container may do with the project directory: "rw" (the default), "ro", "none", or a table of paths such as {".": "ro", "dist": "rw"} (lask spec 10.2).
  • --with Setups of other tools this environment should also carry.
  • --extra_env Any other variable; below --with and the named parameters.

Returns Runnable: The environment, for command { "migrate" } on ... or $[...].

Image migrate/migrate:v4.20.1

bash
lask eval migrate.env --database_url postgres://app:pw@host.docker.internal:5432/app

lib/migrate.lask

flyway.env ​

Flyway.

lask
flyway.env(
  --image: Environment = #flyway/flyway:13.8.0-alpine,
  --url: String | Null = null,
  --user: String | Null = null,
  --password: String | Null = <secret>,
  --locations: String | Null = null,
  --network: String | Null = null,
  --base_access: String | Map<String> | Null = null,
  --with: Array<Record<env: Map<String>, volumes: Array<String>>> = [],
  --extra_env: Map<String> = {}
): Runnable

The image is #flyway/flyway:13.8.0-alpine unless --image names another. Flyway reads its connection from the environment, and sends no telemetry (REDGATE_DISABLE_TELEMETRY=true).

Parameters

  • --image The image to run; another release is passed as image = #flyway/flyway:<tag>.
  • --url FLYWAY_URL, a JDBC URL.
  • --user FLYWAY_USER.
  • --password!! FLYWAY_PASSWORD; masked in the command log.
  • --locations FLYWAY_LOCATIONS, e.g. "filesystem:db/migration".
  • --network The container's network: a Compose network, or "host".
  • --base_access What the container may do with the project directory: "rw" (the default), "ro", "none", or a table of paths such as {".": "ro", "dist": "rw"} (lask spec 10.2).
  • --with Setups of other tools this environment should also carry.
  • --extra_env Any other variable; below --with and the named parameters.

Returns Runnable: The environment, for command { "flyway" } on ... or $[...].

Image flyway/flyway:13.8.0-alpine

bash
lask eval flyway.env --url jdbc:postgresql://host.docker.internal:5432/app --user app

lib/flyway.lask

Released under the MIT License.