How to import data to Edge SQL
This guide explains how to import data into your database using Edge SQL Shell.
Requirements
-
Edge SQL Shell Installed: Ensure that you have the Edge SQL shell properly installed on your system.
-
Database Setup: You need to have a database created. To create a new database within Edge SQL using the Shell, use the command:
.create <database-name>
Importing Data with Edge SQL Shell
- Select a Edge SQL database.
.use database-name
- Import your file.
.import file <csv|xlsx> <file_path> <table_name>
To verify the creation of your table you can use:
.tables
- Select a Edge SQL database.
.use database-name
- Import your SQLite database.
.import sqlite <database> <source_table> <table_name>
To verify the creation of your table you can use:
.tables
- Select a Edge SQL database.
.use database-name
- Import your kaggle database.
Use the following commands to set enviroment variables with your Kaggle credentials:
export KAGGLE_USERNAME="<username>" export KAGGLE_KEY="<kaggle_api_key>"
.import kaggle <dataset> <data_name> <table_name>
To verify the creation of your table you can use:
.tables
Use the following commands to set enviroment variables with 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>
- Select a Edge SQL database.
.use database-name
- Import your MySQL database.
.import mysql <database> <source_table> <table_name>
To verify the creation of your table you can use:
.tables
- Select a Edge SQL database.
Use the following commands to set enviroment variables with 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>
.use database-name
- Import your Postgres database.
.import postgres <database> <source_table> <table_name>
To verify the creation of your table you can use:
.tables
Use the following commands to set enviroment variables with 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>
- Select a Edge SQL database.
.use database-name
- Import your Turso database.
.import turso <database> <source_table> <table_name>
To verify the creation of your table you can use:
.tables
Importing from an SQL File
To import data from an .sql
file containing SQL INSERT
commands, use the .read
command within the Edge SQL Shell. This will execute the SQL statements contained in the file and populate your database with the specified data.
.read <file_name>