datastore
Create, inspect, start, stop, link and query the managed databases that applications use.
A datastore is a managed database. The panel runs it, and hands its connection string to every application linked to it. Use these commands to create a database, check that it is answering, and connect an application to it. Every command also takes --json, --quiet and --help.
| Command | What it does |
|---|---|
stechbd datastore ls | Every datastore, its engine, state and address |
stechbd datastore inspect | One datastore: engine, state, address and whether it is reachable from outside |
stechbd datastore create | Create a database, stating the engine and the major version |
stechbd datastore rm | Delete a datastore and everything in it |
stechbd datastore start | Start a stopped datastore |
stechbd datastore stop | Stop a datastore; everything using it loses its database |
stechbd datastore connection | Print the connection string, password included, and nothing else |
stechbd datastore link | Put the connection string in an application's environment |
stechbd datastore unlink | Take the connection string out of an application's environment |
stechbd datastore query | Run one statement with the engine's own client |
Quick start
Create a database, link it into the application in the current directory, and look at its backup schedule.
stechbd datastore create main --engine postgres --version 16
stechbd datastore link main
stechbd backup lsdatastore createnames the database, the engine and the major version. The version is required.datastore linkwrites the connection string into the application this directory is linked to.backup lsshows the schedules for the database, and when each last backed up and was last restored.
stechbd datastore ls
Lists every datastore your credential can see, with its engine, state and address. Pass --project to show only one project. A datastore in the failed state is flagged below the table, with the command to inspect it.
stechbd datastore ls [--project <project>]| Option | Description |
|---|---|
--project <project> | Show only the datastores in this project. |
# Every datastore
stechbd datastore ls
# One project, as JSON
stechbd datastore ls --project blog --jsonstechbd datastore inspect
Shows one datastore: its engine, state, address, and whether it can be reached from outside the panel. Use it when ls reports a state you do not expect.
stechbd datastore inspect <datastore>| Option | Description |
|---|---|
<datastore> | The datastore, by slug, name or id. Required. |
stechbd datastore inspect main
stechbd datastore inspect main --jsonstechbd datastore create
Creates a database. --engine and --version are both required. The major version is not defaulted, because it decides what the data can be read by, and "latest" changes every month. --server and --size are sent only when given.
stechbd datastore create <name> --engine <engine> --version <version> [--project <project>] [--server <server>] [--size <size>]| Option | Description |
|---|---|
<name> | The name of the new datastore. Required. |
--engine <engine> | One of postgres, mysql, mariadb, mongodb or redis. Required. |
--version <version> | The major version, such as 16 for postgres. Required. |
--project <project> | The project the datastore belongs to. |
--server <server> | The server to create it on. |
--size <size> | A size, by name or id. See stechbd size ls. |
stechbd datastore create main --engine postgres --version 16
stechbd datastore create cache --engine redis --version 7 --project blogstechbd datastore rm
Deletes a datastore and everything in it. At a terminal the command asks first. Outside one it refuses, and changes nothing, unless --yes is passed.
stechbd datastore rm <datastore> [--yes]| Option | Description |
|---|---|
<datastore> | The datastore, by slug, name or id. Required. |
--yes | Skip the question. |
stechbd datastore rm scratch
stechbd datastore rm scratch --yesstechbd datastore start
Starts a datastore that is stopped, and prints its state afterwards.
stechbd datastore start <datastore>| Option | Description |
|---|---|
<datastore> | The datastore, by slug, name or id. Required. |
stechbd datastore start mainstechbd datastore stop
Stops a datastore. Every application using it loses its database until it is started again. At a terminal the command asks first; outside one it refuses unless --yes is passed.
stechbd datastore stop <datastore> [--yes]| Option | Description |
|---|---|
<datastore> | The datastore, by slug, name or id. Required. |
--yes | Skip the question. |
stechbd datastore stop main
stechbd datastore stop main --yesstechbd datastore connection
Prints the connection string, password included, to stdout and nothing else, so a shell can capture exactly that value. The panel records each read. To put the string into an application without printing it, use link instead.
stechbd datastore connection <datastore>| Option | Description |
|---|---|
<datastore> | The datastore, by slug, name or id. Required. |
DATABASE_URL=$(stechbd datastore connection main)
stechbd datastore connection main --jsonstechbd datastore link
Writes the connection string into an application's environment on the panel. The string is not printed. Without --app, the application the current directory is linked to is used. The application sees the variable from its next deployment.
stechbd datastore link <datastore> [--app <app>]| Option | Description |
|---|---|
<datastore> | The datastore, by slug, name or id. Required. |
--app <app> | The application to link. Defaults to the application this directory is linked to. An id, or the slug in the linked project. |
stechbd datastore link main
stechbd datastore link main --app 01J...stechbd datastore unlink
Removes the connection string from an application's environment. At a terminal the command asks first. The datastore itself is not touched.
stechbd datastore unlink <datastore> [--yes] [--app <app>]| Option | Description |
|---|---|
<datastore> | The datastore, by slug, name or id. Required. |
--app <app> | The application to unlink. Defaults to the application this directory is linked to. An id, or the slug in the linked project. |
--yes | Skip the question. |
stechbd datastore unlink main
stechbd datastore unlink main --app 01J... --yesstechbd datastore query
Runs one statement with the engine's own client. The statement is an argument, or it is read from stdin when none is given. The command exits with the client's status: 0 when the statement succeeds, and 1 when the database refuses it. A statement that is cut short by the panel is reported with a warning.
stechbd datastore query <datastore> [<statement>]| Option | Description |
|---|---|
<datastore> | The datastore, by slug, name or id. Required. |
<statement> | The statement, in the engine's own language. Read from stdin when omitted. |
stechbd datastore query main "select count(*) from users"
cat migrate.sql | stechbd datastore query main