Forge SQL Storage REST API for containers
Executes a SQL statement, and with optional params to be substituted in. This is to be used for DML (Data Manipulation) queries.
DML queries are limited to SELECT, INSERT, UPDATE and DELETE statements.
This is recommended for all user facing requests, as the restrictive permissions limits the potential impact of a client being able to successfully use a query injection attack on your app. Using params will use server side params to further mitigate against these attacks.
The DDL API is available for all other statements, and should be used sparingly, and avoid usage where client provided parameters are included.
Forge and OAuth2 apps cannot access this REST resource.
string
Requiredstring
Requiredarray<undefined>
Successful DML execution
1
2
3
4
5
6
7
8
9
10
11
12
curl --request POST \
--url '{FORGE_EGRESS_PROXY_URL}/forge/storage/sql/v1/execute' \
--header 'Accept: application/json' \
--header 'forge-proxy-authorization: Forge as=app,id=invocation-123' \
--header 'Content-Type: application/json' \
--data '{
"query": "SELECT name, age FROM users WHERE name = ? AND age = ?",
"params": [
"Alice",
30
]
}'1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
"rows": [
{
"name": "Alice",
"age": 30
}
],
"metadata": {
"dbExecutionTime": 5,
"responseSize": 12,
"fields": [
{
"catalog": "def",
"name": "name",
"schema": "public",
"characterSet": 33,
"decimals": 0,
"table": "users",
"orgTable": "users",
"orgName": "name",
"flags": 0,
"columnType": 1,
"columnLength": 255
},
{
"catalog": "def",
"name": "age",
"schema": "public",
"characterSet": 33,
"decimals": 0,
"table": "users",
"orgTable": "users",
"orgName": "age",
"flags": 0,
"columnType": 3,
"columnLength": 11
}
]
}
}Executes a SQL statement, and with optional params to be substituted in. This is to be used for DDL (Data Definition) queries.
DDL refers to statements like CREATE, ALTER and DROP. This DDL endpoint is your schema management endpoint and is granted all * permissions to your schema.
We recommended to use this API only when modifying your schema in some way, and doesn’t include user generated params, as there is a chance for higher impact on failure to do so. Use the DML based endpoint for user based requests. The API rate and connection limits are more restrictive than the DML endpoint.
Forge and OAuth2 apps cannot access this REST resource.
string
Requiredstring
Requiredarray<undefined>
Successful DDL execution
1
2
3
4
5
6
7
8
9
curl --request POST \
--url '{FORGE_EGRESS_PROXY_URL}/forge/storage/sql/v1/execute/ddl' \
--header 'Accept: application/json' \
--header 'forge-proxy-authorization: Forge as=app,id=invocation-123' \
--header 'Content-Type: application/json' \
--data '{
"query": "CREATE TABLE IF NOT EXISTS users (id INT PRIMARY KEY, name TEXT NOT NULL, age INT NOT NULL);",
"params": []
}'1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"rows": {
"fieldCount": 0,
"affectedRows": 1,
"insertId": 0,
"info": "",
"serverStatus": 2,
"warningCount": 0
},
"metadata": {
"dbExecutionTime": 10.5,
"responseSize": 1234,
"fields": []
}
}Rate this page: