Interacting with Database
The Nile CLI provides a powerful set of commands for managing your databases. With the CLI, you can create, delete, and manage databases, connect to them using standard PostgreSQL tools, and more.
Available commands:
list
- View all databasesshow
- Display database detailscreate
- Create a new databasedelete
- Remove a databaseregions
- List available regionspsql
- Connect using PostgreSQL CLIconnectionstring
- Get connection details
Setting Workspace
Before using the nile db
command, you can set the workspace to operate in.
Example
The workspace can also be set using the NILE_WORKSPACE
environment variable or by using the flag --workspace
in the command.
Listing Databases
The list
command shows all databases in your workspace.
Options
Flag | Description | Default |
---|---|---|
--format | Output format (human, json, csv) | human |
--workspace | Specific workspace to list from | Current workspace |
Examples
Setting active database in config
You can set the active database in the config file. This simplifies other db commands. Youc an also override the db name using the flag --database
in the command.
Example
Showing Database Details
The show
command provides detailed information about a specific database.
Options
Flag | Description | Default |
---|---|---|
--format | Output format (human, json, csv) | human |
--workspace | Workspace containing the database | Current workspace |
Examples
Listing Regions
The regions
command shows available regions for database creation.
Options
Flag | Description | Default |
---|---|---|
--format | Output format (human, json, csv) | human |
--workspace | Workspace to list regions for | Current workspace |
Examples
Creating Databases
The create
command sets up a new database in your workspace.
Required Options
Flag | Description |
---|---|
--name | Name for the new database |
--region | Region to create the database in |
Additional Options
Flag | Description | Default |
---|---|---|
--format | Output format (human, json, csv) | human |
--workspace | Workspace to create in | Current workspace |
Examples
Use the nile db region command to see the available regions. After creating the db, you can use the nile db show command to see the database details. You also want to set the config to the db you just created.
Deleting Databases
The delete
command removes a database permanently.
Options
Flag | Description | Default |
---|---|---|
--force | Skip confirmation prompt | false |
--workspace | Workspace containing the database | Current workspace |
Examples
Using PostgreSQL CLI
The psql
command opens an interactive PostgreSQL terminal.
Options
Flag | Description | Default |
---|---|---|
--workspace | Workspace containing the database | Current workspace |
Examples
Getting Connection Strings
The connectionstring
command provides database connection details. Currently, it only supports the psql format.
Examples
Common Workflows
Setting Up a New Database
Managing Multiple Environments
Database Cleanup
Getting Help
For detailed help on any command:
Related Topics
- Connecting to Nile - Authentication guide
- Working with Tenants - Tenant management
- Configuration - CLI configuration
- Workspaces - Workspace management
Was this page helpful?