How to manage an Edge SQL database

Edge SQL allows you to create and manage relational databases. This guide covers how to create, list, and delete a database using the Azion API.

Go to Edge SQL reference

After creating a database, read How to create an Edge SQL query to populate your database.


Creating a database

Run the following POST request in your terminal, replacing [TOKEN VALUE] with your personal token and name with the desired database name to create a new database:

Terminal window
curl --location 'https://api.azion.com/v4/edge_sql/databases' \
--header 'Authorization: Token [TOKEN VALUE]' \
--header 'Content-Type: application/json' \
--data '{
"name": "my-database"
}'

You should receive the following response:

{
"state": "pending",
"data": {
"id": 118,
"name": "my-database",
"client_id": "6832h",
"status": "creating",
"created_at": "2024-04-18T11:22:59.468536Z",
"updated_at": "2024-04-18T11:22:59.468586Z",
"deleted_at": null
}
}

Listing all databases

Run the following GET request in your terminal, replacing [TOKEN VALUE] with your personal token:

Terminal window
curl --location 'https://api.azion.com/v4/edge_sql/databases' \
--header 'Authorization: Token [TOKEN VALUE]'

You should receive the following response:

{
"count": 1,
"links": {
"first": null,
"last": null,
"next": null,
"prev": null
},
"results": [
{
"id": 118,
"name": "my-database",
"client_id": "6832h",
"status": "created",
"created_at": "2024-04-15T15:15:10.200345Z",
"updated_at": "2024-04-15T15:15:47.332481Z",
"deleted_at": null
}
]
}

This endpoint lists all the databases created in your account.


Listing a specific database

Run the following GET request in your terminal, replacing [TOKEN VALUE] with your personal token and {id_database} with the specific id of the database you’ve retrived in the GET all request:

Terminal window
curl --location 'https://api.azion.com/v4/edge_sql/databases/{id_database}' \
--header 'Authorization: Token [TOKEN VALUE]'

You should receive the following response:

{
"data": {
"id": 118,
"name": "my-database",
"client_id": "6832h",
"status": "created",
"created_at": "2024-04-18T11:22:59.468536Z",
"updated_at": "2024-04-18T11:23:18.492883Z",
"deleted_at": null
}
}

This endpoint lists only the information regarding the specific database whose ID you’ve provided.


Deleting a database

Run the following DELETE request in your terminal, replacing [TOKEN VALUE] with your personal token and {id_database} with the ID of the database you want to delete:

Terminal window
curl --location --request DELETE 'https://api.azion.com/v4/edge_sql/databases/{id_database}' \
--header 'Authorization: Token [TOKEN VALUE]'

Learn how to manage Azion Edge SQL databases effectively. Watch the video below:


Contributors