Get Started with dh#

This walkthrough creates a private people database in your DoltHub account. You need a DoltHub account, permission to create a private database, and dh installed.

Replace OWNER in every command with your DoltHub username. Use a new database name if people already exists. The SQL commands below use the main branch; substitute your database’s branch name if it differs.

Log in#

dh auth login
dh auth status

The first command opens your browser. After approving access, return to the terminal. auth status shows the account and host in use. See Authentication for token-based use.

Create a database#

dh db create OWNER/people --private

The command prints the database identifier and its web URL. To create a public database instead, choose --public when creating it.

Add a table and rows#

Create a small table:

dh sql --write --db OWNER/people --branch main \
  "CREATE TABLE people (id INT PRIMARY KEY, name VARCHAR(100), city VARCHAR(100))"

Then add two rows:

dh sql --write --db OWNER/people --branch main \
  "INSERT INTO people VALUES (1, 'Ada', 'London'), (2, 'Grace', 'New York')"

Each write runs as a DoltHub job. By default, dh waits for it to finish and prints its status. Wait for a successful result before running the next command. These remote SQL writes commit their changes on DoltHub; you do not need to run a local dolt commit or dolt push.

Query the data#

dh sql --db OWNER/people --branch main \
  "SELECT id, name, city FROM people ORDER BY id"

You should see Ada and Grace with their cities. Use --branch for both reads and writes against a branch. Reads also accept --ref for a branch, tag, or commit; supply only one selector. Writes require --write and --branch.

For structured results:

dh sql --db OWNER/people --branch main \
  "SELECT id, name FROM people ORDER BY id" --json columns,rows,status

Open the database#

dh browse --db OWNER/people

To avoid repeating --db, save a default with dh config set db OWNER/people. Explicit --db flags override that default; Configuration explains the full selection order.

Next, make a change through a pull request, import a file, or explore the command reference.