Make sure to first set up your PlanetScale developer environment. Once you’ve installed the pscale CLI, you can interact with PlanetScale and manage your databases straight from the command line.
This command imports external databases into PlanetScale Postgres. Today it supports Cloudflare D1 (SQLite) through the d1 sub-command group. For other migration paths, see the Postgres imports overview.Usage:
pscale import d1 <SUB-COMMAND> <FLAG>
Branch-scoped sub-commands take the positional form <DATABASE_NAME> [BRANCH_NAME], defaulting to the default branch. The organization comes from your pscale config (pscale org) or the --org flag.
pscale import d1 supports the human (default) and json output formats. The csv format is not supported.
Some of the sub-commands have additional flags unique to the sub-command. This section covers what each of those does. See the above table for which context.
Sub-command flag
Type
Description
Applicable sub-commands
--input <FILE>
string
Path to the D1 SQL export produced by wrangler d1 export (required for lint, convert-schema, and start)
Lint and build the import plan without loading Postgres; prints a migration ID for the real run
start
--migration-id <MIGRATION_ID>
string
Migration ID from a prior start --dry-run (required for verify, status, and complete)
start, verify, status, complete
--method <METHOD>
string
Import method: pgloader (exports ≥ 1 GB) or psql (exports < 1 GB; schema via psql, data via pgloader). Chosen automatically by export size when omitted
start
--dbname <NAME>
string
Destination PostgreSQL database name (default postgres)
start, verify
--sqlite <FILE>
string
Path to a local SQLite file to use for source row counts