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.

nile db [command] [options]

Available commands:

  • list - View all databases
  • show - Display database details
  • create - Create a new database
  • delete - Remove a database
  • regions - List available regions
  • psql - Connect using PostgreSQL CLI
  • connectionstring - Get connection details

Setting Workspace

Before using the nile db command, you can set the workspace to operate in.

nile config --workspace <workspaceName>

Example

Workspace Example
# Set workspace to 'test'
nile config --workspace test

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.

nile db list [options]

Options

FlagDescriptionDefault
--formatOutput format (human, json, csv)human
--workspaceSpecific workspace to list fromCurrent workspace

Examples

List Examples
# Basic list
nile db list

# JSON format
nile db list --format json

# Specific workspace
nile db list --workspace test

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.

nile config --database <databaseName>

Example

nile config --database determined_house

Showing Database Details

The show command provides detailed information about a specific database.

nile db show [databaseName] [options]

Options

FlagDescriptionDefault
--formatOutput format (human, json, csv)human
--workspaceWorkspace containing the databaseCurrent workspace

Examples

Show Examples
# Show specific database
nile db show myapp-db

# Show current database
nile db show

# Detailed JSON output
nile db show myapp-db --format json

Listing Regions

The regions command shows available regions for database creation.

nile db regions [options]

Options

FlagDescriptionDefault
--formatOutput format (human, json, csv)human
--workspaceWorkspace to list regions forCurrent workspace

Examples

Region Examples
# List all regions
nile db regions

# JSON format
nile db regions --format json

# Check regions in specific workspace
nile db regions --workspace test

Creating Databases

The create command sets up a new database in your workspace.

nile db create [options]

Required Options

FlagDescription
--nameName for the new database
--regionRegion to create the database in

Additional Options

FlagDescriptionDefault
--formatOutput format (human, json, csv)human
--workspaceWorkspace to create inCurrent workspace

Examples

Create Examples
# Create new database
nile db create --name myapp_db --region AWS_US_WEST_2

# Create in specific workspace
nile db create --name prod_db --region AWS_US_WEST_2 --workspace test

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.

nile db delete [databaseName] [options]

Options

FlagDescriptionDefault
--forceSkip confirmation promptfalse
--workspaceWorkspace containing the databaseCurrent workspace

Examples

Delete Examples
# Delete with confirmation
nile db delete myapp_db

# Force delete without confirmation
nile db delete myapp_db --force

# Delete from specific workspace
nile db delete myapp_db --workspace development

Using PostgreSQL CLI

The psql command opens an interactive PostgreSQL terminal.

nile db psql [databaseName] [options]

Options

FlagDescriptionDefault
--workspaceWorkspace containing the databaseCurrent workspace

Examples

PSQL Examples
# Connect to database using the config
nile db psql 

# Connect in specific db and workspace
nile db psql --name determined_house --workspace test

Getting Connection Strings

The connectionstring command provides database connection details. Currently, it only supports the psql format.

nile db connectionstring --psql

Examples

Connection String Examples
# Get basic connection string
nile db connectionstring --psql

Common Workflows

Setting Up a New Database

New Database Workflow
# 1. List available regions
nile db regions

# 2. Create database
nile db create --name myapp_db --region AWS_US_WEST_2

# 3. Verify creation
nile db show myapp_db

# 4. Connect to database
nile db psql myapp_db

Managing Multiple Environments

Environment Management
# Development setup
nile db create --name dev_db --region AWS_US_WEST_2 --workspace development

# Production setup
nile db create --name prod_db --region AWS_US_EAST_1 --workspace production

# Get connection strings
nile db connectionstring dev_db --workspace development
nile db connectionstring prod_db --workspace production

Database Cleanup

Cleanup Workflow
# 1. List all databases
nile db list

# 2. Check database details
nile db show old_db

# 3. Delete unused database
nile db delete old_db --force

# 4. Verify deletion
nile db list

Getting Help

For detailed help on any command:

# General database help
nile db help

# Specific command help
nile db help create
nile db help psql

Was this page helpful?