Databases
Connect Ghostrow to Postgres, MySQL and MariaDB, SQLite or SQL Server: URL formats, TLS options, the permissions each command needs, and when to use a schema file instead.
Pass a connection URL with --db. Ghostrow picks the database type from the start of the URL.
| Database | URL | Plans |
|---|---|---|
| Postgres | postgres://user:password@host:5432/dbname (or postgresql://) | All plans |
| SQLite | sqlite:path/to/app.db, or a bare path ending in .db, .sqlite, .sqlite3 or .db3 | All plans |
| MySQL and MariaDB | mysql://user:password@host:3306/dbname (or mariadb://) | Paid plans |
| SQL Server | mssql://user:password@host:1433/dbname (or sqlserver://) | Paid plans |
Free works with Postgres and SQLite. On Free, MySQL and SQL Server stop with exit code 4 and the message MySQL needs a paid license; Free works with Postgres and SQLite.
ghostrow seed --db postgres://app:secret@localhost:5432/app_test --rows 5000 --seed 42
Put the URL in an environment variable and pass it with --db "$DATABASE_URL". Ghostrow does not read DATABASE_URL by itself. Percent-encode special characters in the user name and password. In error messages Ghostrow replaces the password with ****.
Postgres
Ghostrow reads the tables in the current schema of the connection (current_schema(), which follows the role's search_path). Arrays are written as text. Dates and timestamps are kept as the text Postgres sends, with no time zone conversion.
TLS follows the sslmode parameter in the URL:
sslmode | Result |
|---|---|
disable | No TLS |
require | TLS, certificate not checked |
verify-ca, verify-full | TLS, certificate checked |
| not set | TLS on for hosts of well-known managed providers (for example neon.tech, supabase.co, rds.amazonaws.com), without certificate checks. Otherwise the driver default |
channel_binding is accepted and ignored.
MySQL and MariaDB
The URL needs a database name. Ghostrow reads that database through information_schema. It supports MySQL 8 and MariaDB 10.5 or later. Older MySQL versions work, but without CHECK constraints.
Turn TLS on with ?ssl=true (also read from sslmode and ssl-mode). Any value except false, disable, disabled or 0 enables it. The certificate is checked only when the value contains verify, for example ?ssl-mode=VERIFY_IDENTITY. TLS is also on by default for hosts such as psdb.cloud, rds.amazonaws.com and aivencloud.com.
SQL Server
The database comes from the URL path, or from ?database=name, and falls back to master. Two options in the query string control TLS:
encrypt(defaulttrue, orfalseforlocalhost,127.0.0.1and::1)trustServerCertificate(defaultfalse, ortruefor those local hosts)
ghostrow seed --db "mssql://sa:secret@localhost:1433/shop?encrypt=false" --dry-run
SQLite
Ghostrow loads the whole file into memory, and writes it back when it inserts rows. If the file does not exist, the run stops with SQLite file not found. Ghostrow does not create databases: create the file and its tables first.
What Ghostrow does to the database
| Command | Reads | Writes |
|---|---|---|
seed --dry-run | The schema, and up to 50 rows per table to confirm what columns hold | Nothing |
seed --db | The same, plus existing values of unique columns (so new rows do not collide) and the largest numeric key per table | Rows, in one transaction. A failed run rolls back, so nothing is half-written |
haunt --db | The same as seed --dry-run | Edge-case rows. With --tests, Ghostrow deletes them again by primary key after each test run |
twin --from | The schema and up to 50,000 rows per table, in memory | Nothing. Read-only access is enough |
twin --to | The schema, and existing unique values | Rows, in one transaction. The tables must already exist |
So seed --db and haunt --db need INSERT rights, haunt --tests also needs DELETE, and Postgres needs permission to reset the sequences behind serial and identity columns after the insert. Use a test or staging database for these. twin --from is the only command meant for a database with real data, and it needs SELECT only.
Schema files instead of a live database
With --db alone, seed inserts into the database. Add --out <dir> to read the schema from the database and write files instead; the database is then only read (1.0.1 and later).
--schema reads a schema without connecting. Use it when you have no database running, in CI, or when you do not want any connection to production. It gives the same understanding of the columns, minus the sampled values. See ORM and schema files.
Use --db or --schema, not both. Without either, Ghostrow stops with Point Ghostrow at a database with --db <url>, or at a schema file or folder with --schema <path>.