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.
EdgeSQL> help
Example:
EdgeSQL> help .dump
.databases
Lists all databases.
EdgeSQL> .databases
.use
Switches to a specific database.
EdgeSQL> .use <database-name>
.tables
Lists all tables in the database.
EdgeSQL> .tables
.schema
Describes the schema of a specific table.
EdgeSQL> .schema <table-name>
.dbinfo
Retrieves information about the current database.
EdgeSQL> .dbinfo
.read
Loads and executes SQL queries from a file.
EdgeSQL> .read <file_path>
.create
Creates a new database.
EdgeSQL> .create <database-name>
.destroy
Destroys a specific database.
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.
EdgeSQL> .output stdout
Example using a file as destination:
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.
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:
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:
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.
EdgeSQL> .import <params> <table-name>
By running the help
command you can get a list of the possible parameters for importing data:
EdgeSQL> help .import
You will receive a response similar to this:
.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.
EdgeSQL> .dbsize
.exit
Exits the EdgeSQL Shell.
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.
export AZION_TOKEN="<your_auth_token_here>"
Kaggle credentials
Use the following commands to set your Kaggle credentials:
export KAGGLE_USERNAME="<username>" export KAGGLE_KEY="<kaggle_api_key>"
MySQL credentials
Use the following commands to set your MySQL credentials:
export MYSQL_USERNAME="<username>" export MYSQL_PASSWORD="<password>" export MYSQL_HOST="<host_address>"
Optional settings for MySQL:
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:
export POSTGRES_USERNAME="<username>" export POSTGRES_PASSWORD="<password>" export POSTGRES_HOST="<host_address>"
Optional settings for PostgreSQL:
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:
export TURSO_DATABASE_URL=<https://<db_name>-<organization>.turso.io export TURSO_AUTH_TOKEN=<token>
Optional settings for Turso:
export TURSO_ENCRYPTION_KEY=<encryption_key>
Contributors