Run SQL against a SQL database
Runs SQL against the database and returns the resulting rows — empty for statements that return none, such as DDL. Bind positional ? placeholders with params rather than interpolating values into the SQL string.
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.storage.sqldbs.actions.query('id', {
sql: 'SELECT * FROM users WHERE name = ?',
});
console.log(response.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
response = client.storage.sqldbs.actions.query(
id="id",
sql="SELECT * FROM users WHERE name = ?",
)
print(response.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.Storage.Sqldbs.Actions.Query(
context.TODO(),
"id",
telnyx.StorageSqldbActionQueryParams{
SQL: "SELECT * FROM users WHERE name = ?",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.storage.sqldbs.actions.ActionQueryParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
ActionQueryParams params = ActionQueryParams.builder()
.sql("SELECT * FROM users WHERE name = ?")
.build();
var response = client.storage().sqldbs().actions().query("id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.storage.sqldbs.actions.query("id", sql: "SELECT * FROM users WHERE name = ?")
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$response = $client->storage->sqldbs->actions->query(
'id',
sql: 'SELECT * FROM users WHERE name = ?',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx storage:sqldbs:actions query \
--api-key 'My API Key' \
--id id \
--sql 'SELECT * FROM users WHERE name = ?'curl --request POST \
--url https://api.telnyx.com/v2/storage/sqldbs/{id}/actions/query \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sql": "SELECT * FROM users WHERE name = ?",
"params": [
"alice"
]
}
'{
"data": {
"results": [
{}
],
"success": true,
"count": 1,
"duration": 2.5,
"meta": {
"duration": 1.2,
"rows_read": 3,
"rows_written": 0,
"last_row_id": 0,
"changes": 0
}
}
}{
"errors": [
{
"code": "10005",
"detail": "The requested function does not exist or you don't have access to it",
"meta": {
"url": "https://docs.telnyx.com/api/errors/10005"
},
"source": {
"parameter": "id",
"pointer": "/id"
},
"title": "Function not found"
}
]
}{
"errors": [
{
"code": "10005",
"detail": "The requested function does not exist or you don't have access to it",
"meta": {
"url": "https://docs.telnyx.com/api/errors/10005"
},
"source": {
"parameter": "id",
"pointer": "/id"
},
"title": "Function not found"
}
]
}{
"errors": [
{
"code": "10005",
"detail": "The requested function does not exist or you don't have access to it",
"meta": {
"url": "https://docs.telnyx.com/api/errors/10005"
},
"source": {
"parameter": "id",
"pointer": "/id"
},
"title": "Function not found"
}
]
}{
"errors": [
{
"code": "10005",
"detail": "The requested function does not exist or you don't have access to it",
"meta": {
"url": "https://docs.telnyx.com/api/errors/10005"
},
"source": {
"parameter": "id",
"pointer": "/id"
},
"title": "Function not found"
}
]
}{
"errors": [
{
"code": "10005",
"detail": "The requested function does not exist or you don't have access to it",
"meta": {
"url": "https://docs.telnyx.com/api/errors/10005"
},
"source": {
"parameter": "id",
"pointer": "/id"
},
"title": "Function not found"
}
]
}{
"errors": [
{
"code": "10005",
"detail": "The requested function does not exist or you don't have access to it",
"meta": {
"url": "https://docs.telnyx.com/api/errors/10005"
},
"source": {
"parameter": "id",
"pointer": "/id"
},
"title": "Function not found"
}
]
}{
"errors": [
{
"code": "10005",
"detail": "The requested function does not exist or you don't have access to it",
"meta": {
"url": "https://docs.telnyx.com/api/errors/10005"
},
"source": {
"parameter": "id",
"pointer": "/id"
},
"title": "Function not found"
}
]
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Path Parameters
SQL database ID
Body
The SQL to run, and any positional bind parameters
The SQL to run. Use positional ? placeholders and supply the values in params rather than interpolating them into this string.
"SELECT * FROM users WHERE name = ?"
Positional bind parameters, in placeholder order. Each value is a string, a number, a boolean, or null; booleans are cast to 1/0. The count must match the number of ? placeholders exactly — a mismatch is rejected with 422 rather than binding null for the ones you left out. (Not enforced for multi-statement scripts or named parameters, where the placeholder count is not the number bound.)
["alice"]
Response
The SQL result
Show child attributes
Show child attributes
Was this page helpful?
import Telnyx from 'telnyx';
const client = new Telnyx({
apiKey: process.env['TELNYX_API_KEY'], // This is the default and can be omitted
});
const response = await client.storage.sqldbs.actions.query('id', {
sql: 'SELECT * FROM users WHERE name = ?',
});
console.log(response.data);import os
from telnyx import Telnyx
client = Telnyx(
api_key=os.environ.get("TELNYX_API_KEY"), # This is the default and can be omitted
)
response = client.storage.sqldbs.actions.query(
id="id",
sql="SELECT * FROM users WHERE name = ?",
)
print(response.data)
package main
import (
"context"
"fmt"
"github.com/team-telnyx/telnyx-go"
"github.com/team-telnyx/telnyx-go/option"
)
func main() {
client := telnyx.NewClient(
option.WithAPIKey("My API Key"),
)
response, err := client.Storage.Sqldbs.Actions.Query(
context.TODO(),
"id",
telnyx.StorageSqldbActionQueryParams{
SQL: "SELECT * FROM users WHERE name = ?",
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.Data)
}
package com.telnyx.sdk.example;
import com.telnyx.sdk.client.TelnyxClient;
import com.telnyx.sdk.client.okhttp.TelnyxOkHttpClient;
import com.telnyx.sdk.models.storage.sqldbs.actions.ActionQueryParams;
public final class Main {
private Main() {}
public static void main(String[] args) {
TelnyxClient client = TelnyxOkHttpClient.fromEnv();
ActionQueryParams params = ActionQueryParams.builder()
.sql("SELECT * FROM users WHERE name = ?")
.build();
var response = client.storage().sqldbs().actions().query("id", params);
}
}require "telnyx"
telnyx = Telnyx::Client.new(api_key: "My API Key")
response = telnyx.storage.sqldbs.actions.query("id", sql: "SELECT * FROM users WHERE name = ?")
puts(response)<?php
require_once dirname(__DIR__) . '/vendor/autoload.php';
use Telnyx\Client;
use Telnyx\Core\Exceptions\APIException;
$client = new Client(apiKey: getenv('TELNYX_API_KEY') ?: 'My API Key');
try {
$response = $client->storage->sqldbs->actions->query(
'id',
sql: 'SELECT * FROM users WHERE name = ?',
);
var_dump($response);
} catch (APIException $e) {
echo $e->getMessage();
}telnyx storage:sqldbs:actions query \
--api-key 'My API Key' \
--id id \
--sql 'SELECT * FROM users WHERE name = ?'curl --request POST \
--url https://api.telnyx.com/v2/storage/sqldbs/{id}/actions/query \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"sql": "SELECT * FROM users WHERE name = ?",
"params": [
"alice"
]
}
'{
"data": {
"results": [
{}
],
"success": true,
"count": 1,
"duration": 2.5,
"meta": {
"duration": 1.2,
"rows_read": 3,
"rows_written": 0,
"last_row_id": 0,
"changes": 0
}
}
}{
"errors": [
{
"code": "10005",
"detail": "The requested function does not exist or you don't have access to it",
"meta": {
"url": "https://docs.telnyx.com/api/errors/10005"
},
"source": {
"parameter": "id",
"pointer": "/id"
},
"title": "Function not found"
}
]
}{
"errors": [
{
"code": "10005",
"detail": "The requested function does not exist or you don't have access to it",
"meta": {
"url": "https://docs.telnyx.com/api/errors/10005"
},
"source": {
"parameter": "id",
"pointer": "/id"
},
"title": "Function not found"
}
]
}{
"errors": [
{
"code": "10005",
"detail": "The requested function does not exist or you don't have access to it",
"meta": {
"url": "https://docs.telnyx.com/api/errors/10005"
},
"source": {
"parameter": "id",
"pointer": "/id"
},
"title": "Function not found"
}
]
}{
"errors": [
{
"code": "10005",
"detail": "The requested function does not exist or you don't have access to it",
"meta": {
"url": "https://docs.telnyx.com/api/errors/10005"
},
"source": {
"parameter": "id",
"pointer": "/id"
},
"title": "Function not found"
}
]
}{
"errors": [
{
"code": "10005",
"detail": "The requested function does not exist or you don't have access to it",
"meta": {
"url": "https://docs.telnyx.com/api/errors/10005"
},
"source": {
"parameter": "id",
"pointer": "/id"
},
"title": "Function not found"
}
]
}{
"errors": [
{
"code": "10005",
"detail": "The requested function does not exist or you don't have access to it",
"meta": {
"url": "https://docs.telnyx.com/api/errors/10005"
},
"source": {
"parameter": "id",
"pointer": "/id"
},
"title": "Function not found"
}
]
}{
"errors": [
{
"code": "10005",
"detail": "The requested function does not exist or you don't have access to it",
"meta": {
"url": "https://docs.telnyx.com/api/errors/10005"
},
"source": {
"parameter": "id",
"pointer": "/id"
},
"title": "Function not found"
}
]
}