Using skysqlcli with the DBaaS API
This page is part of MariaDB's Documentation.
The parent of this page is: MariaDB SkySQL DBaaS API
Topics on this page:
Overview
SkySQL operations can be automated using the MariaDB SkySQL DBaaS API.
The skysqlcli
command-line utility is one way to access the SkySQL DBaaS API.
The examples on this page demonstrate common service management operations. For a full list of supported operations and command-line options, see skysqlcli
Commands.
The skysqlcli
utility is a Technical Preview. Software in Tech Preview should not be used for production workloads.
For a guided walkthrough on how to use the skysqlcli
utility, see "Get Started Using SkySQL DBaaS API".
Use Cases
Scripting or automating the creation or deletion of SkySQL services
Retrieving the default database credentials for a SkySQL service
Updating the IP allowlist for a SkySQL service
Compatibility
Distributed Transactions
Multi-Node Analytics
Replicated Transactions
Single Node Analytics
Single Node Transactions
Installation
Access MariaDB Downloads for the
skysqlcli
utility.In the "OS" dropdown, select your operating system.
Click the "Download" button to download the binary for your operating system.
Rename the downloaded file.
On Linux:
$ mv skysqlcli-linux skysqlcli
On macOS:
$ mv skysqlcli-macos skysqlcli
On Microsoft Windows:
C:\> ren skysqlcli-windows.exe skysqlcli.exe
Set the executable's permissions, so that it can be executed.
On Linux and macOS:
$ chmod 0755 skysqlcli
On Microsoft Windows, the default file permissions allow the file to be executed. If you encounter issues, check the file's Access Control List (ACL) to confirm your user account or security group have
Read & Execute
permissions on the executable file.Place the executable in an appropriate directory on your system, such as:
Operating Systems
Typical Executable Directories
Linux
macOS
/usr/local/bin
$HOME/bin
Microsoft Windows
Any directory referenced in the
PATH
environment variable
Authentication and Authorization
skysqlcli
interfaces with the MariaDB SkySQL DBaaS API. The DBaaS API requires authentication and authorization.
Obtain a SkySQL API Key with
SkySQL API: Databases
scopeProvide the SkySQL API key to the
skysqlcli
command-line interface.Substitute your SkySQL API key in place of
YOUR_SKYSQL_API_KEY
using one of the following methods:The
--api-key
command-line option can be used:$ skysqlcli get services \ --api-key 'YOUR_SKYSQL_API_KEY'
A YAML configuration file can be used:
api-key: 'YOUR_SKYSQL_API_KEY'
The default configuration file is
$HOME/.skysqlcli.yaml
, but a different configuration file can be specified using the--config
command-line option.The
SKYSQL_API_KEY
environment variable can be used:$ export SKYSQL_API_KEY='YOUR_SKYSQL_API_KEY'
Retrieve Service Information
The following examples retrieve information about SkySQL services.
These types of operations are commonly automated to confirm service configuration, prepare to execute other commands, and to confirm service readiness to receive traffic.
Services List
Similar to the "Your Services" list in the SkySQL Portal, you can retrieve the list of all active services you (or your SkySQL Team) have created.
Detail | Description |
---|---|
CLI Reference | |
Behavior |
|
Command-Line Example | $ skysqlcli get services \
| jq .
|
Retrieve Service ID by Service Name
skysqlcli
commands related to specific services require that the Service ID be specified. The Service ID can be looked-up from the Service Name.
Detail | Description |
---|---|
CLI Reference | |
Behavior | Returns JSON with server IDs |
Options |
|
Command-Line Example | $ skysqlcli get services \
--name 'doc-test-tx-single' \
| jq '{ "name": .[0].name, "id": .[0].id }'
|
Sample Response | {
"name": "doc-test-tx-single",
"id": "db00000001"
}
|
Service Status
Service status indicates when a new service is ready to receive connections.
Detail | Description |
---|---|
CLI Reference | |
Behavior |
|
Command-Line Example | For a Service ID of $ skysqlcli get status 'db00000001' \
| jq .
|
Sample Response | {
"status": "Running"
}
|
Create a Service
The following examples cover activities commonly performed when creating a new SkySQL service.
The use of automation to create services helps ensure repeatability and the correct creation of services of the desired specification.
Create a Database Service
SkySQL enables creation of services with multiple cloud providers and regions, customized to your specifications.
Detail | Description |
---|---|
Detail | Description |
CLI Reference | |
Behavior |
|
Options |
|
Command-Line Example | For example, create a Single Node Transactions service in AWS using the following options: $ skysqlcli create service \
--name 'doc-test-tx-single' \
--provider 'AWS' \
--region 'us-east-2' \
--release-version 'MariaDB Enterprise Server 10.6.4-1' \
--replicas '0' \
--size 'Sky-2x8' \
--storage '100' \
--tier 'Foundation' \
--topology 'Single Node Transactions' \
--volume-iops '100' \
| jq .
|
Add IP Address to Allowlist
By default, access to SkySQL services is blocked by a firewall. An IP allowlist specifies which IP addresses are permitted to connect to the service.
Detail | Description |
---|---|
CLI Reference | |
Behavior |
|
Command-Line Example | For a Service ID of $ skysqlcli create allowed-address 'db00000001' 'CLIENT_IP_ADDRESS/SUBNET_MASK'
To check the status of this operation: $ skysqlcli get allowlist-status 'db00000001' \
| jq .
|
Sample Output | {
"status": "Enforcing"
}
|
Obtain Database Credentials
Default credentials are set at time of service creation.
Detail | Description |
---|---|
CLI Reference | |
Behavior |
|
Command-Line Example | For a Service ID of $ skysqlcli get credentials 'db00000001' \
| jq .
|
Sample Response | {
"username": "DB00000001",
"password": "SKYSQL_DEFAULT_PASSWORD"
}
|
Obtain Service Connection Details
Service details are used to connect to the database service.
Detail | Description |
---|---|
CLI Reference | |
Behavior |
|
Command-Line Example | For a Service ID of $ skysqlcli get service 'db00000001' \
| jq '{ "provider": .provider, "host": .fqdn, "read_only_port": .read_only_port, "read_write_port": .read_write_port, "ssl_tls": .ssl_tls }'
|
Sample Response | {
"provider": "Amazon AWS",
"host": "doc-test-tx-single.mdb0000001.db.skysql.net",
"read_only_port": "",
"read_write_port": "5001",
"ssl_tls": "Enabled"
}
|
Use the Service
After creating a SkySQL service, it is typical to:
Perform testing, such as with sample applications
Delete a Service
Deletion is non-reversible. Deletion removes the service and all data in the service. Charges for a service stop accruing when the service is deleted.
Ephemeral environments (such as Continuous Integration and testing) are commonly deleted when no longer needed.
Production environments are rarely deleted. Before deleting a service, consider whether production workloads are present.
Detail | Description |
---|---|
CLI Reference | |
Behavior |
|
Command-Line Example | For a Service ID of $ skysqlcli delete service 'db00000001' \
| jq .
|