How to use EdgeSQL Shell commands

EdgeSQL Shell provides a command-line interface to manage and interact with your Edge SQL databases. Beyond executing SQL queries, it offers a comprehensive set of commands for database administration and configuration.

This guide covers the available commands for interacting with the EdgeSQL service and managing environment variables.

EdgeSQL Shell commands

help

Shows information about the available commands or a specific command.

Terminal window
EdgeSQL> help

Example:

Terminal window
EdgeSQL> help .dump

.databases

Lists all databases.

Terminal window
EdgeSQL> .databases

.use

Switches to a specific database.

Terminal window
EdgeSQL> .use <database-name>

.tables

Lists all tables in the database.

Terminal window
EdgeSQL> .tables

.schema

Describes the schema of a specific table.

Terminal window
EdgeSQL> .schema <table-name>

.dbinfo

Retrieves information about the current database.

Terminal window
EdgeSQL> .dbinfo

.read

Loads and executes SQL queries from a file.

Terminal window
EdgeSQL> .read <file_path>

.create

Creates a new database.

Terminal window
EdgeSQL> .create <database-name>

.destroy

Destroys a specific database.

Terminal window
EdgeSQL> .destroy <database-name>

.output

Sets the output destination. Pass stdout as parameter to output to the console or inform a file path to define it as the output destination.

Terminal window
EdgeSQL> .output stdout

Example using a file as destination:

Terminal window
EdgeSQL> .output /file.csv

.dump

Renders the table structure as SQL. After running the output command and setting the output to a file, the dump command will save the output to the selected file.

Terminal window
EdgeSQL> .dump <table-name>

You can pass the options --schema-only or --data-only to optionally render only the schema or the data of the table.

Example:

Terminal window
EdgeSQL> .dump --schema-only <table-name>

.mode

Sets the output mode. You can choose one of the following options:

  • excel
  • tabular
  • csv
  • json
  • html
  • markdown
  • raw

Example:

Terminal window
EdgeSQL> .mode tabular

.import

Imports data from an external source into the table. You can import data from a file or from a MySQL, Postgres, Kaggle or Turso database.

Terminal window
EdgeSQL> .import <params> <table-name>

By running the help command you can get a list of the possible parameters for importing data:

Terminal window
EdgeSQL> help .import

You will receive a response similar to this:

Terminal window
.import: Import data from file files, Kaggle datasets, or databases into a database table.
Args:
arg (str): The import command and its arguments.
Command Formats:
.import file <csv|xlsx> <file_path> <table_name>: Import data from a file CSV or Excel file.
.import kaggle <dataset> <data_name> <table_name>: Import data from a Kaggle dataset.
.import mysql <database> <source_table> <table_name>: Import data from a MySQL database table.
.import postgres <database> <source_table> <table_name>: Import data from PostgreSQL database table.
.import turso <database> <source_table> <table_name>: Import data from Turso database.
Examples:
.import file csv /path/to/file.csv my_table
.import kaggle joonasyoon/google-doodles list.csv list
.import mysql mydb_name source_table_name my_table
.import turso <database> <source_table> <table_name>

.dbsize

Gets the size of the current database in MB.

Terminal window
EdgeSQL> .dbsize

.exit

Exits the EdgeSQL Shell.

Terminal window
EdgeSQL> .exit

Environment variables

When using the EdgeSQL Shell to import data from external sources, you can send the credentials and tokens as environment variables byt using the export command. This command is also used for setting your Azion personal token.

Personal token

You can send your personal token as an environment variable in EdgeSQL Shell.

Terminal window
export AZION_TOKEN="<your_auth_token_here>"

Kaggle credentials

Use the following commands to set your Kaggle credentials:

Terminal window
export KAGGLE_USERNAME="<username>"
export KAGGLE_KEY="<kaggle_api_key>"

MySQL credentials

Use the following commands to set your MySQL credentials:

Terminal window
export MYSQL_USERNAME="<username>"
export MYSQL_PASSWORD="<password>"
export MYSQL_HOST="<host_address>"

Optional settings for MySQL:

Terminal window
export MYSQL_PORT=<port>
# For TLS connection
export MYSQL_SSL_CA="<ssl_ca>"
export MYSQL_SSL_CERT="<ssl_cert>"
export MYSQL_SSL_KEY="<ssl_key>"
export MYSQL_SSL_VERIFY_CERT=<True|False>

PostgreSQL credentials

Use the following commands to set your PostgreSQL credentials:

Terminal window
export POSTGRES_USERNAME="<username>"
export POSTGRES_PASSWORD="<password>"
export POSTGRES_HOST="<host_address>"

Optional settings for PostgreSQL:

Terminal window
export POSTGRES_PORT=<port>
# For TLS connection
export POSTGRES_SSL_CA="<ssl_ca>"
export POSTGRES_SSL_CERT="<ssl_cert>"
export POSTGRES_SSL_KEY="<ssl_key>"
export POSTGRES_SSL_VERIFY_CERT=<True|False>

Turso credentials

Use the following commands to set your Turso credentials:

Terminal window
export TURSO_DATABASE_URL=<https://<db_name>-<organization>.turso.io
export TURSO_AUTH_TOKEN=<token>

Optional settings for Turso:

Terminal window
export TURSO_ENCRYPTION_KEY=<encryption_key>
Go to EdgeSQL Shell installation guide

Contributors