---
name: azion-import-data-with-the-edgesql-shell
description: >-
  Load a CSV file, a SQL script, or a table from another database into a SQL Database table with the EdgeSQL Shell import commands.
---

# Import data with the EdgeSQL Shell

You load data into a [SQL Database](/en/documentation/platform/sql-database/) table with EdgeSQL Shell, from a CSV or XLSX file, a SQL script, a local SQLite database, or a table held by MySQL, PostgreSQL, Kaggle, or Turso. The three local sources read a path on your machine and need no credentials. The four remote sources read theirs from environment variables you export before you start the shell.

For the complete argument form of every command below, the output modes, and the full table of credential variables, refer to [EdgeSQL Shell](/en/documentation/platform/sql-database/edgesql-shell/).

> **Caution**
>
> EdgeSQL Shell does not start on a clean install. Every command fails before the `EdgeSQL>` prompt appears, with `ImportError: cannot import name 'Configuration' from 'kaggle.api.kaggle_api_extended'`: `commands/import.py` imports the Kaggle module unconditionally while the shell starts, and the pinned `kaggle==1.8.3` no longer defines that symbol. Downgrading does not rescue it on a machine with no Kaggle credentials, because the package authenticates inside its own `__init__.py` — `1.6.17` and `1.7.4` fail there instead. A fix is pending.
>
> Stubbing that one import out locally leaves the rest of the tool working. It is a local workaround, not a supported step. For the interfaces that run the same SQL until the fix ships, refer to [Troubleshooting](/en/documentation/platform/sql-database/troubleshooting/).

---

## Prerequisites

- SQL Database enabled on your account. The product is in Preview and is not enabled by default, so request access through [Technical Support](/en/documentation/support/).
- EdgeSQL Shell installed, with its virtual environment active. Refer to [Install the EdgeSQL Shell](/en/documentation/guides/application-development/data/install-edge-sql-shell/).
- A database to import into. Create one as in [Create and manage databases](/en/documentation/guides/application-development/data/manage-sql-database/), or from the shell itself with `.create <database-name>`.
- A [personal token](/en/documentation/guides/platform/account-and-billing/personal-tokens/) exported as `AZION_TOKEN`. The shell authenticates with it.
- The credentials of the source you read from, for the four remote sources. Each section below names the variables its source needs.

---

## Import a CSV or XLSX file

`.import file` reads a file on your machine and writes its rows into a table. It accepts a CSV or an XLSX file and no other format, and it is the only source whose argument form names a file type. To import a CSV file:

1. **Select the database**

   ```bash
   .use <database-name>
   ```

   Every command that follows runs against this database.

2. **Import the file**

   ```bash
   .import file csv /path/to/cities.csv cities
   ```

   The last two arguments are the path to the file and the name of the target table. Pass `xlsx` in place of `csv` for an Excel file. A three-row file imports in about five seconds.

   The shell writes a progress bar while it chunks the data, and ends on one line:

   ```text
   Data imported successfully into table 'cities'.
   ```

The table holds the rows of the file, and `.tables` lists it among the tables of the database.

---

## Run a SQL file

`.read` runs the SQL statements a file holds against the database in use. Use it for a file of `INSERT` statements, or for a file that creates a schema and fills it in one pass. To run the file:

1. **Select the database**

   ```bash
   .use <database-name>
   ```

2. **Run the file**

   ```bash
   .read /path/to/schema.sql
   ```

   The shell answers with one line:

   ```text
   SQL statements from /path/to/schema.sql executed successfully.
   ```

The statements have run in the order the file holds them, and the rows they insert are readable with a `SELECT` at the `EdgeSQL>` prompt.

---

## Import from a SQLite database

`.import sqlite` copies one table out of a SQLite database file on your machine. Its arguments are the path to the file, the table to read, and the table to write. To import the table:

1. **Select the database**

   ```bash
   .use <database-name>
   ```

2. **Import the table**

   ```bash
   .import sqlite /path/to/local.db products products
   ```

   The shell answers with one line:

   ```text
   Data imported successfully into table 'products'.
   ```

The target table holds the rows of the source table, with their column types preserved.

---

## Import from MySQL

`.import mysql` reads one table from a MySQL server. It needs `MYSQL_USERNAME`, `MYSQL_PASSWORD`, and `MYSQL_HOST`. `MYSQL_PORT` is optional, and the `MYSQL_SSL_*` variables configure a TLS connection. For every variable and its accepted values, refer to [Environment variables](/en/documentation/platform/sql-database/edgesql-shell/#environment-variables).

Azion has not run this import. The command form comes from the shell's own help text, so no output is shown for it. To import the table:

1. **Export the MySQL credentials**

   In the terminal, before you start the shell:

   ```bash
   export MYSQL_USERNAME="<username>"
   export MYSQL_PASSWORD="<password>"
   export MYSQL_HOST="<host_address>"
   ```

2. **Select the database**

   ```bash
   .use <database-name>
   ```

3. **Import the table**

   ```bash
   .import mysql <database> <source_table> <table_name>
   ```

   `<database>` is the database on the MySQL server, `<source_table>` the table to read, and `<table_name>` the table to write in SQL Database.

The target table holds the rows read from the MySQL table.

---

## Import from PostgreSQL

`.import postgres` reads one table from a PostgreSQL server. It needs `POSTGRES_USERNAME`, `POSTGRES_PASSWORD`, and `POSTGRES_HOST`. `POSTGRES_PORT` is optional, and the `POSTGRES_SSL_*` variables configure a TLS connection. For every variable and its accepted values, refer to [Environment variables](/en/documentation/platform/sql-database/edgesql-shell/#environment-variables).

Azion has not run this import. The command form comes from the shell's own help text, so no output is shown for it. To import the table:

1. **Export the PostgreSQL credentials**

   In the terminal, before you start the shell:

   ```bash
   export POSTGRES_USERNAME="<username>"
   export POSTGRES_PASSWORD="<password>"
   export POSTGRES_HOST="<host_address>"
   ```

2. **Select the database**

   ```bash
   .use <database-name>
   ```

3. **Import the table**

   ```bash
   .import postgres <database> <source_table> <table_name>
   ```

   `<database>` is the database on the PostgreSQL server, `<source_table>` the table to read, and `<table_name>` the table to write in SQL Database.

The target table holds the rows read from the PostgreSQL table.

---

## Import from Kaggle

`.import kaggle` reads one file out of a Kaggle dataset. It needs `KAGGLE_USERNAME` and `KAGGLE_KEY`, and it is the only source whose arguments name a dataset and a file inside it rather than a database and a table.

Azion has not run this import. The command form comes from the shell's own help text, so no output is shown for it. Kaggle is also the source that stops the shell from starting: the module behind this command imports the Kaggle package at startup, which is the failure the caution above describes. To import the file:

1. **Export the Kaggle credentials**

   In the terminal, before you start the shell:

   ```bash
   export KAGGLE_USERNAME="<username>"
   export KAGGLE_KEY="<kaggle_api_key>"
   ```

2. **Select the database**

   ```bash
   .use <database-name>
   ```

3. **Import the file**

   ```bash
   .import kaggle joonasyoon/google-doodles list.csv list
   ```

   The arguments are the dataset, the file inside it, and the target table. This example is the one the shell's help text prints.

The target table holds the rows of the file read from the dataset.

---

## Import from Turso

`.import turso` reads one table from a Turso database. It needs `TURSO_DATABASE_URL` and `TURSO_AUTH_TOKEN`, and `TURSO_ENCRYPTION_KEY` is optional.

Azion has not run this import. The command form comes from the shell's own help text, so no output is shown for it. To import the table:

1. **Export the Turso credentials**

   In the terminal, before you start the shell:

   ```bash
   export TURSO_DATABASE_URL="https://<db_name>-<organization>.turso.io"
   export TURSO_AUTH_TOKEN="<token>"
   ```

2. **Select the database**

   ```bash
   .use <database-name>
   ```

3. **Import the table**

   ```bash
   .import turso <database> <source_table> <table_name>
   ```

   `<database>` is the database on the Turso server, `<source_table>` the table to read, and `<table_name>` the table to write in SQL Database.

The target table holds the rows read from the Turso table.

---

## Next steps

- [EdgeSQL Shell](/en/documentation/platform/sql-database/edgesql-shell.md): Every command the shell accepts, the argument form of each import source, the output modes, and the credential variables.
- [Create tables and query data](/en/documentation/guides/application-development/data/create-tables-sql-database.md): Read the imported rows back, and write the SQL that creates, updates, and deletes them.
- [Install the EdgeSQL Shell](/en/documentation/guides/application-development/data/install-edge-sql-shell.md): The clone, the virtual environment, and the token that put the shell on your machine.
- [Troubleshooting](/en/documentation/platform/sql-database/troubleshooting.md): The symptoms SQL Database and its shell return, and what each one means.
