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 creates a secure connection to a database branch for a local client.
pscale connect <DATABASE_NAME> <BRANCH_NAME> <FLAG>
If there is only one branch available on the database, you can leave off
|Run the specified command after successfully connecting to the database.|
|Environment variable name that contains the exposed Database URL. Default is |
|Protocol for the exposed URL (by default |
|Help with the |
|Local host to bind and listen for connections. Default is |
|The organization of the database you want to connect to.|
|Local port to bind and listen for connections. Default is |
|PlanetScale Database remote network address. By default, the remote address is automatically populated from the PlanetScale API.|
|Define the access level with a role|
Available roles for the
--role flag are:
|The API token to use for authenticating against the PlanetScale API.|
|The base URL for the PlanetScale API. Default is |
|Config file. Default is |
|Enable debug mode.|
|Show output in a specific format. Possible values: |
|Disable color output.|
|The service token for authenticating.|
|The service token ID for authenticating.|
pscale connect <DATABASE_NAME> <BRANCH_NAME> --execute 'node app.js'
This command connects to the specified PlanetScale branch and runs the
node app.js command. Since no
--execute-env-url flag was passed, it uses the default
DATABASE_URL environment variable. You can find a full example of this in our Node quickstart.