|
| 1 | +--- |
| 2 | +title: 'PlanetScale CLI commands: data-imports' |
| 3 | +subtitle: 'Use the PlanetScale CLI “data-imports” command to create, and manage database imports.' |
| 4 | +date: '2024-07-15' |
| 5 | +meta: |
| 6 | + title: 'CLI reference: data-imports' |
| 7 | +--- |
| 8 | + |
| 9 | +## Getting Started |
| 10 | + |
| 11 | +Make sure to first [set up your PlanetScale developer environment](/docs/concepts/planetscale-environment-setup). Once you've installed the `pscale` CLI, you can interact with PlanetScale and manage your databases straight from the command line. |
| 12 | + |
| 13 | +## The `service-token` command |
| 14 | + |
| 15 | +This command allows you to manage your [database import](/docs/imports/database-imports) from the PlanetScale CLI. |
| 16 | + |
| 17 | +**Usage:** |
| 18 | + |
| 19 | +```bash |
| 20 | +pscale data-imports <SUB-COMMAND> <FLAG> |
| 21 | +``` |
| 22 | + |
| 23 | +### Available sub-commands |
| 24 | + |
| 25 | +| **Sub-command** | **Sub-command flags** | **Description** | |
| 26 | +| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | |
| 27 | +| `cancel <DATABASE_NAME>` | `--name`\*, `--force` | Cancel data import request | |
| 28 | +| `detach-external-database` | `--name`\*, `--force` | Detach external database that is used as a source for PlanetScale database | |
| 29 | +| `get <DATABASE_NAME>` | `--name`\* | Get the current state of a data import request into a PlanetScale database | |
| 30 | +| `lint` | `--database <EXTERNAL_DATABASE_NAME>`\*, `--host <EXTERNAL_HOST_NAME>`\*, `--password <EXTERNAL_DATABASE_PASS>`\*, `--ssl-mode <SSL_MODE>`\*, `--username <EXTERNAL_DATABASE_USER>`\*, `--port <PORT>`, `--ssl-certificate-authority <SSL_CA>`, `--ssl-client-certificate <SSL_CERT>`, `--ssl-client-key <SSL_CLIENT_KEY>`, `--ssl-server-name <SSL_SERVER_NAME>` | Lint external database for compatibility with PlanetScale | |
| 31 | +| `make-primary` | `--name`\*, `--force` | Mark PlanetScale's database as the Primary, and the external database as Replica | |
| 32 | +| `make-replica` | `--name`\*, `--force` | Mark PlanetScale's database as the Replica, and the external database as Primary | |
| 33 | +| `start` | `--database <EXTERNAL_DATABASE_NAME>`\*, `--host <EXTERNAL_HOST_NAME_>`\*, `--port <EXTERNAL_PORT_NUMBER>`, `--name <PLANETSCALE_DATABASE_NAME>`\*, `--username <EXTERNAL_DATABASE_USERNAME>`\*, `--password <EXTERNAL_DATABASE_PASSWORD>`\*, `--region <PLANETSCALE_DATABASE_REGION>`, `--ssl-certificate-authority <SSL_CA>`, `--ssl-client-certificate <SSL_CERT>`, `--ssl-client-key <SSL_CLIENT_KEY>`, `--ssl-mode <SSL_MODE>`\*, `--ssl-server-name <SSL_SERVER_NAME>`, `--dry-run` | Start importing data from an external database | |
| 34 | + |
| 35 | +> \* _Flag is required_ |
| 36 | +
|
| 37 | +#### Sub-command flag descriptions |
| 38 | + |
| 39 | +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. |
| 40 | + |
| 41 | +| **Sub-command flag** | **Description** | **Applicable sub-commands** | |
| 42 | +| ----------------------------------------- | ---------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ | |
| 43 | +| `--database <PLANETSCALE_DATABASE_NAME>` | Name of the PlanetScale database for which you wish to cancel the import | `cancel`, `lint` | |
| 44 | +| `--name <PLANETSCALE_DATABASE_NAME>` | Name of the PlanetScale database you are importing into | `cancel`, `get`, `detach-external-database`, `make-primary`, `make-replica`, `start` | |
| 45 | +| `--force` | Make PlanetScale database replica or primary without confirmation | `cancel`, `detach-external-database`, `make-primary`, `make-replica` | |
| 46 | +| `--database <EXTERNAL_DATABASE_NAME>` | Name of the external database | `lint`, `start` | |
| 47 | +| `--dry-run` | Only run compatibility check; do not start the import (true by default) | `start` | |
| 48 | +| `--host <EXTERNAL_HOST_NAME_>` | Host name of the external database | `start`, `lint` | |
| 49 | +| `--port <EXTERNAL_PORT_NUMBER>` | Port number to connect to external database (default 3306) | `start`, `lint` | |
| 50 | +| `--username <EXTERNAL_DATABASE_USERNAME>` | Username of the external database you are importing from | `start`, `lint` | |
| 51 | +| `--password <EXTERNAL_DATABASE_PASSWORD>` | External database password | `start`, `lint` | |
| 52 | +| `--region <PLANETSCALE_DATABASE_REGION>` | Region of the PlanetScale database you're importing into | `start` | |
| 53 | +| `--ssl-certificate-authority <SSL_CA>` | The full CA certificate chain | `start`, `lint` | |
| 54 | +| `--ssl-client-certificate <SSL_CERT>` | Client Certificate to authenticate PlanetScale with your database server | `start`, `lint` | |
| 55 | +| `--ssl-client-key <SSL_CLIENT_KEY>` | Private key for the client certificate | `start`, `lint` | |
| 56 | +| `--ssl-mode <SSL_MODE>` | SSL verification mode, allowed values: `disabled`, `preferred`, `required`, `verify_ca`, `verify_identity` | `start`, `lint` | |
| 57 | +| `--ssl-server-name <SSL_SERVER_NAME>` | SSL server name override | `start`, `lint` | |
| 58 | + |
| 59 | +### Available flags |
| 60 | + |
| 61 | +| **Flag** | **Description** | |
| 62 | +| --------------------------- | ------------------------------------- | |
| 63 | +| `-h`, `--help` | View help for `service-token` command | |
| 64 | +| `--org <ORGANIZATION_NAME>` | The organization for the current user | |
| 65 | + |
| 66 | +### Global flags |
| 67 | + |
| 68 | +| **Command** | **Description** | |
| 69 | +| ------------------------------- | ------------------------------------------------------------------------------------ | |
| 70 | +| `--api-token <TOKEN>` | The API token to use for authenticating against the PlanetScale API. | |
| 71 | +| `--api-url <URL>` | The base URL for the PlanetScale API. Default is `https://api.planetscale.com/`. | |
| 72 | +| `--config <CONFIG_FILE>` | Config file. Default is `$HOME/.config/planetscale/pscale.yml`. | |
| 73 | +| `--debug` | Enable debug mode. | |
| 74 | +| `-f`, `--format <FORMAT>` | Show output in a specific format. Possible values: `human` (default), `json`, `csv`. | |
| 75 | +| `--no-color` | Disable color output. | |
| 76 | +| `--org` | The organization for the current user. | |
| 77 | +| `--service-token <TOKEN>` | The service token for authenticating. | |
| 78 | +| `--service-token-id <TOKEN_ID>` | The service token ID for authenticating. | |
0 commit comments