Getting Started
Make sure to first set up your PlanetScale developer environment. Once you’ve installed thepscale
CLI, you can interact with PlanetScale and manage your databases straight from the command line.
The role
command
Manage database roles for a Postgres database branch. This command is only supported for Postgres databases.
Usage:
Available sub-commands
Sub-Command | Product | Description |
---|---|---|
create | Postgres | Create a new role for a Postgres database branch |
delete | Postgres | Delete a role |
get | Postgres | Retrieve information about a specific role |
list | Postgres | List all roles for a Postgres database branch |
renew | Postgres | Renew a role’s expiration |
reset-default | Postgres | Reset the credentials for the default postgres role |
update | Postgres | Update a role’s name |
Available flags
Flag | Description |
---|---|
-h , --help | View help for role command |
--org string | The organization for the current user |
Global flags
Command | Description |
---|---|
--api-token <TOKEN> | The API token to use for authenticating against the PlanetScale API. |
--api-url <URL> | The base URL for the PlanetScale API. Default is https://api.planetscale.com/ . |
--config <CONFIG_FILE> | Config file. Default is $HOME/.config/planetscale/pscale.yml . |
--debug | Enable debug mode. |
-f , --format <FORMAT> | Show output in a specific format. Possible values: human (default), json , csv . |
--no-color | Disable color output. |
--service-token <TOKEN> | The service token for authenticating. |
--service-token-id <TOKEN_ID> | The service token ID for authenticating. |
Examples
The create
sub-command
Create a new role for a Postgres database branch:
Usage:
--inherited-roles string
- Comma-separated list of role names to inherit privileges from. Common values are ‘pg_read_all_data’ for read access, ‘pg_write_all_data’ for write access, and ‘postgres’ for admin access.--ttl duration
- TTL defines the time to live for the role. Durations such as “30m”, “24h”, or bare integers such as “3600” (seconds) are accepted. The default TTL is 0s, which means the role will never expire.
The delete
sub-command
Delete a role:
Usage:
--force
- Delete a role without confirmation--successor string
- Role to transfer ownership to before deletion. Usually ‘postgres’.
delete
, rm
Example:
The get
sub-command
Retrieve information about a specific role:
Usage:
The list
sub-command
List all roles for a Postgres database branch:
Usage:
-w
,--web
- List roles in your web browser.
list
, ls
Example:
The renew
sub-command
Renew a role’s expiration:
Usage:
The reset-default
sub-command
Reset the credentials for the default postgres
role:
WarningBe careful with this command. If you are currently using the default
postgres
role credentials for connecting to your database, running this command will reset the password and your existing connections will stop working.--force
- Force reset without confirmation
The update
sub-command
Update a role’s name:
Usage:
--name string
- New name for the role