Skip to content

Commit 9b65862

Browse files
LuizaVSantosMarianaReisAlcantaraguiafonso-ol
authored
[EDU-4916] added import to edge sql guides (#1665)
* added import to edge sql guides * added description * Update src/content/docs/en/pages/guides/edge-sql/import-data.mdx Co-authored-by: MarianaReisAlcantara <mariana.alcantara@azion.com> * fixed duplicaded mysql * fix: missing tab * Update src/content/docs/pt-br/pages/guias/edge-sql/importar-dados.mdx Co-authored-by: MarianaReisAlcantara <mariana.alcantara@azion.com> * aded guides to edgesql home * Apply suggestions from code review Co-authored-by: Guilherme Afonso Oliveira <guilherme.oliveira@azion.com> * added: enviroment variable settings for sql * fix: add kaggle credentials step --------- Co-authored-by: MarianaReisAlcantara <mariana.alcantara@azion.com> Co-authored-by: Guilherme Afonso Oliveira <guilherme.oliveira@azion.com>
1 parent a71a338 commit 9b65862

File tree

4 files changed

+456
-0
lines changed

4 files changed

+456
-0
lines changed
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
---
2+
title: How to import data to Edge SQL
3+
description: >-
4+
This guide explains how to import data into your database using Edge SQL Shell.
5+
meta_tags: edge sql, sql, query, crud, data, database
6+
namespace: docs_import_data_edgesql
7+
permalink: /documentation/products/guides/import-data-edge-sql/
8+
---
9+
import Tabs from '~/components/tabs/Tabs';
10+
import LinkButton from 'azion-webkit/linkbutton';
11+
12+
This guide explains how to import data into your database using Edge SQL Shell.
13+
14+
## Requirements
15+
16+
- **Edge SQL Shell Installed**: Ensure that you have the Edge SQL shell properly [installed on your system](/en/documentation/products/store/sql/install-edge-sql-shell/).
17+
18+
- **Database Setup**: You need to have a database created. To create a new database within Edge SQL using the Shell, use the command:
19+
20+
```sh
21+
.create <database-name>
22+
```
23+
24+
## Importing Data with Edge SQL Shell
25+
26+
<Tabs client:visible sharedStore="Databases">
27+
<fragment slot="tab.file">CSV or XLSX</fragment>
28+
<fragment slot="tab.kaggle">Kaggle</fragment>
29+
<fragment slot="tab.mysql">MySQL</fragment>
30+
<fragment slot="tab.sqlite">SQLite</fragment>
31+
<fragment slot="tab.postgres">Postgres</fragment>
32+
<fragment slot="tab.turso">Turso</fragment>
33+
34+
<fragment slot="panel.file">
35+
<slot name="file" />
36+
37+
1. Select a Edge SQL database.
38+
39+
```shell
40+
.use database-name
41+
```
42+
43+
2. Import your file.
44+
45+
```
46+
.import file <csv|xlsx> <file_path> <table_name>
47+
```
48+
To verify the creation of your table you can use:
49+
50+
```shell
51+
.tables
52+
```
53+
</fragment>
54+
55+
<fragment slot="panel.kaggle">
56+
<slot name="Kaggle" />
57+
58+
1. Select a Edge SQL database.
59+
60+
```shell
61+
.use database-name
62+
```
63+
64+
2. Import your kaggle database.
65+
66+
Use the following commands to set enviroment variables with your Kaggle credentials:
67+
68+
```sh
69+
export KAGGLE_USERNAME="<username>"
70+
export KAGGLE_KEY="<kaggle_api_key>"
71+
```
72+
73+
```shell
74+
.import kaggle <dataset> <data_name> <table_name>
75+
```
76+
To verify the creation of your table you can use:
77+
78+
```shell
79+
.tables
80+
```
81+
</fragment>
82+
83+
<fragment slot="panel.mysql">
84+
<slot name="MySQL" />
85+
86+
Use the following commands to set enviroment variables with your MySQL credentials:
87+
88+
```sh
89+
export MYSQL_USERNAME="<username>"
90+
export MYSQL_PASSWORD="<password>"
91+
export MYSQL_HOST="<host_address>"
92+
```
93+
94+
Optional settings for MySQL:
95+
96+
```sh
97+
export MYSQL_PORT=<port>
98+
99+
# For TLS connection
100+
export MYSQL_SSL_CA="<ssl_ca>"
101+
export MYSQL_SSL_CERT="<ssl_cert>"
102+
export MYSQL_SSL_KEY="<ssl_key>"
103+
export MYSQL_SSL_VERIFY_CERT=<True|False>
104+
```
105+
106+
1. Select a Edge SQL database.
107+
108+
```shell
109+
.use database-name
110+
```
111+
112+
2. Import your MySQL database.
113+
114+
```shell
115+
.import mysql <database> <source_table> <table_name>
116+
```
117+
To verify the creation of your table you can use:
118+
119+
```shell
120+
.tables
121+
```
122+
123+
</fragment>
124+
<fragment slot="panel.postgres">
125+
<slot name="Postgres" />
126+
127+
1. Select a Edge SQL database.
128+
129+
Use the following commands to set enviroment variables with your PostgreSQL credentials:
130+
131+
```sh
132+
export POSTGRES_USERNAME="<username>"
133+
export POSTGRES_PASSWORD="<password>"
134+
export POSTGRES_HOST="<host_address>"
135+
```
136+
137+
Optional settings for PostgreSQL:
138+
139+
```sh
140+
export POSTGRES_PORT=<port>
141+
142+
# For TLS connection
143+
export POSTGRES_SSL_CA="<ssl_ca>"
144+
export POSTGRES_SSL_CERT="<ssl_cert>"
145+
export POSTGRES_SSL_KEY="<ssl_key>"
146+
export POSTGRES_SSL_VERIFY_CERT=<True|False>
147+
```
148+
149+
```shell
150+
.use database-name
151+
```
152+
153+
2. Import your Postgres database.
154+
155+
```shell
156+
.import postgres <database> <source_table> <table_name>
157+
```
158+
To verify the creation of your table you can use:
159+
160+
```shell
161+
.tables
162+
```
163+
164+
</fragment>
165+
166+
<fragment slot="panel.sqlite">
167+
<slot name="SQLite" />
168+
169+
1. Select a Edge SQL database.
170+
171+
```shell
172+
.use database-name
173+
```
174+
175+
2. Import your SQLite database.
176+
177+
```shell
178+
.import sqlite <database> <source_table> <table_name>
179+
```
180+
To verify the creation of your table you can use:
181+
182+
```shell
183+
.tables
184+
```
185+
186+
</fragment>
187+
<fragment slot="panel.turso">
188+
<slot name="Turso" />
189+
190+
Use the following commands to set enviroment variables with your Turso credentials:
191+
192+
```sh
193+
export TURSO_DATABASE_URL=<https://<db_name>-<organization>.turso.io
194+
export TURSO_AUTH_TOKEN=<token>
195+
```
196+
197+
Optional settings for Turso:
198+
```sh
199+
export TURSO_ENCRYPTION_KEY=<encryption_key>
200+
```
201+
202+
1. Select a Edge SQL database.
203+
204+
```shell
205+
.use database-name
206+
```
207+
208+
2. Import your Turso database.
209+
210+
```shell
211+
.import turso <database> <source_table> <table_name>
212+
```
213+
To verify the creation of your table you can use:
214+
215+
```shell
216+
.tables
217+
```
218+
219+
</fragment>
220+
</Tabs>
221+
222+
## Importing from an SQL File
223+
224+
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.
225+
226+
```shell
227+
.read <file_name>
228+
```

src/content/docs/en/pages/main-menu/reference/store/edge-sql/edge-sql.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ There are two ways to build a database through Edge SQL: using the Edge SQL REST
3434
| Create queries with REST API | [How to create and query data on Edge SQL](/en/documentation/products/guides/create-tables-edge-sql/) |
3535
| Retrieve data from a database | [How to retrieve data from a database with Edge SQL and Edge Functions](/en/documentation/products/guides/edge-sql/retrieve-data-with-edge-functions/) |
3636
| Get to know Edge SQL Vector Search | [Edge SQL Vector Search reference](/en/documentation/products/store/edge-sql/vector-search/) |
37+
| Import data to Edge SQL | [How to import data guide ](/en/documentation/products/guides/import-data-edge-sql/) |
3738

3839
---
3940

0 commit comments

Comments
 (0)