databases
Creates, updates, deletes, gets or lists a databases resource.
Overview​
| Name | databases |
| Type | Resource |
| Id | ovh.hosting_web.databases |
Fields​
The following fields are returned by SELECT queries:
- get
- list
successful operation
| Name | Datatype | Description |
|---|---|---|
name | string | Database name (like mydb.mysql.db or mydb.postgres.db) |
sqlperso_id | integer | Which SQLPerso this database is linked to (if any) (wire: sqlpersoId) |
task_id | integer | The task ID working on this database (wire: taskId) |
database_service_deprecated | boolean | Whether service database is deprecated (wire: databaseServiceDeprecated) |
database_type | string | Database service type (extra, included, optional) (wire: databaseType) |
dumps | integer | The number of available dumps associated to this database |
gui_url | string | URL for the graphical user interface (wire: guiURL) |
last_check | string (date-time) | Date of the last check quota (wire: lastCheck) |
mode | string | Mode of your database (besteffort, classic, module) |
port | integer | The port on where to contact this database |
quota_size | object | Space allowed (wire: quotaSize) |
quota_used | object | Space used (wire: quotaUsed) |
server | string | Your database server name |
state | string | Database state (close, ok, readonly) |
status | string | The database status (checking, created, creating, deleting, dumping, importing, locked, optimizing, restoring, updating) |
type | string | Type of your database (mariadb, mongodb, mysql, postgresql, redis) |
user | string | Database user name |
version | string | Database version following the database type (10, 10.1, 10.11, 10.2, 10.3, 10.4, 10.5, 10.6, 11, 12, 13, 15, 3.2, 3.4, 4.0, 5.1, 5.5, 5.6, 5.7, 6.0, 7.0, 8.0, 8.4, 9.4, 9.5, 9.6) |
version_support | string | Indicates the current support state of your database version (beta, deprecated, stable) (wire: versionSupport) |
Database
| Name | Datatype | Description |
|---|---|---|
name | string | Database name (like mydb.mysql.db or mydb.postgres.db) |
sqlperso_id | integer | Which SQLPerso this database is linked to (if any) (wire: sqlpersoId) |
task_id | integer | The task ID working on this database (wire: taskId) |
database_service_deprecated | boolean | Whether service database is deprecated (wire: databaseServiceDeprecated) |
database_type | string | Database service type (extra, included, optional) (wire: databaseType) |
dumps | integer | The number of available dumps associated to this database |
gui_url | string | URL for the graphical user interface (wire: guiURL) |
last_check | string (date-time) | Date of the last check quota (wire: lastCheck) |
mode | string | Mode of your database (besteffort, classic, module) |
port | integer | The port on where to contact this database |
quota_size | object | Space allowed (wire: quotaSize) |
quota_used | object | Space used (wire: quotaUsed) |
server | string | Your database server name |
state | string | Database state (close, ok, readonly) |
status | string | The database status (checking, created, creating, deleting, dumping, importing, locked, optimizing, restoring, updating) |
type | string | Type of your database (mariadb, mongodb, mysql, postgresql, redis) |
user | string | Database user name |
version | string | Database version following the database type (10, 10.1, 10.11, 10.2, 10.3, 10.4, 10.5, 10.6, 11, 12, 13, 15, 3.2, 3.4, 4.0, 5.1, 5.5, 5.6, 5.7, 6.0, 7.0, 8.0, 8.4, 9.4, 9.5, 9.6) |
version_support | string | Indicates the current support state of your database version (beta, deprecated, stable) (wire: versionSupport) |
Methods​
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
get | select | name, service_name | Get a database. Returns the type, version, server, port, user, quota and status of the database, and the URL of its management tool. | |
list | select | service_name | mode, name, server, type, user, x_pagination_mode | List databases. Returns the names of the databases of the hosting. Filter them by mode, name, server, type or user. |
create | insert | service_name, capabilitie, type, user | Create a database. Creates a MariaDB, MySQL, PostgreSQL or Redis database with its user, and returns the task. The quota applies only to extraSqlPerso databases. | |
delete | delete | name, service_name | Delete a database. Deletes the database and returns the task. Its dumps are kept until their automatic deletion date. | |
change_password | exec | name, serviceName, password | Change the database password. Changes the password of the database user and returns the task. Available when changePassword is true in the database capabilities. | |
copy_restore | exec | name, serviceName, copyId | Restore a database copy. Restores a copy into the database and returns the task. Set flushDatabase to true to empty the database first. | |
import | exec | name, serviceName, documentId | Import a dump. Imports a dump file uploaded with /me/documents into the database, and returns the task. Set flushDatabase to true to empty the database first. | |
request | exec | name, serviceName, action | Run a database action. Runs an action on the database and returns the task. CHECK_QUOTA refreshes the space used by the database. | |
restore | exec | name, serviceName, date | Restore a database backup. Restores the database from a daily or weekly backup and returns the task. Set sendEmail to true to receive an email when it is done. |
Parameters​
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
api_host | string | The OVHcloud API host. Selected by OVH_ENDPOINT (ovh-eu, ovh-ca or ovh-us; default ovh-eu). (default: api.eu.ovhcloud.com, x-stackQL-envVarSelector: {"envVar":"OVH_ENDPOINT","default":"ovh-eu","values":{"ovh-eu":"api.eu.ovhcloud.com","ovh-ca":"api.ca.ovhcloud.com","ovh-us":"api.us.ovhcloud.com"}}) |
name | string | Database name (like mydb.mysql.db or mydb.postgres.db) |
serviceName | string | The internal name of your hosting |
service_name | string | The internal name of your hosting (wire: serviceName) |
mode | string | Filter the value of mode property (=) |
name | string | Filter the value of name property (like) |
server | string | Filter the value of server property (like) |
type | string | Filter the value of type property (=) |
user | string | Filter the value of user property (like) |
x_pagination_mode | string | Sent as CachedObjectList-Pages by default so the list returns the full objects rather than their identifiers. (wire: X-Pagination-Mode) |
SELECT examples​
- get
- list
Get a database. Returns the type, version, server, port, user, quota and status of the database, and the URL of its management tool.
SELECT
name,
sqlperso_id,
task_id,
database_service_deprecated,
database_type,
dumps,
gui_url,
last_check,
mode,
port,
quota_size,
quota_used,
server,
state,
status,
type,
user,
version,
version_support
FROM ovh.hosting_web.databases
WHERE name = '{{ name }}' -- required
AND service_name = '{{ service_name }}' -- required
;
List databases. Returns the names of the databases of the hosting. Filter them by mode, name, server, type or user.
SELECT
name,
sqlperso_id,
task_id,
database_service_deprecated,
database_type,
dumps,
gui_url,
last_check,
mode,
port,
quota_size,
quota_used,
server,
state,
status,
type,
user,
version,
version_support
FROM ovh.hosting_web.databases
WHERE service_name = '{{ service_name }}' -- required
AND mode = '{{ mode }}'
AND name = '{{ name }}'
AND server = '{{ server }}'
AND type = '{{ type }}'
AND user = '{{ user }}'
AND x_pagination_mode = '{{ x_pagination_mode }}'
;
INSERT examples​
- create
- Manifest
Create a database. Creates a MariaDB, MySQL, PostgreSQL or Redis database with its user, and returns the task. The quota applies only to extraSqlPerso databases.
INSERT INTO ovh.hosting_web.databases (
capabilitie,
password,
quota,
type,
user,
version,
service_name
)
SELECT
'{{ capabilitie }}' /* required */,
'{{ password }}',
{{ quota }},
'{{ type }}' /* required */,
'{{ user }}' /* required */,
'{{ version }}',
'{{ service_name }}'
RETURNING
id,
object_id,
done_date,
function,
last_update,
object_type,
start_date,
status
;
# Description fields are for documentation purposes
- name: databases
props:
- name: service_name
value: "{{ service_name }}"
description: Required parameter for the databases resource.
- name: capabilitie
value: "{{ capabilitie }}"
description: |
Type of your database
valid_values: ['extraSqlPerso', 'local', 'privateDatabase', 'sqlLocal', 'sqlPerso', 'sqlPro']
- name: password
value: "{{ password }}"
description: |
Database password
- name: quota
value: {{ quota }}
description: |
Quota assign to your database. Only for extraSql
valid_values: ['25', '100', '200', '256', '400', '512', '800', '1024']
- name: type
value: "{{ type }}"
description: |
Type you want for your database
valid_values: ['mariadb', 'mysql', 'postgresql', 'redis']
- name: user
value: "{{ user }}"
description: |
Database user name. Must begin with your hosting login and must be in lower case
- name: version
value: "{{ version }}"
description: |
Version you want for your database following the type
valid_values: ['10', '10.1', '10.11', '10.2', '10.3', '10.4', '10.5', '10.6', '11', '12', '13', '15', '3.2', '3.4', '4.0', '5.1', '5.5', '5.6', '5.7', '6.0', '7.0', '8.0', '8.4', '9.4', '9.5', '9.6']
DELETE examples​
- delete
Delete a database. Deletes the database and returns the task. Its dumps are kept until their automatic deletion date.
DELETE FROM ovh.hosting_web.databases
WHERE name = '{{ name }}' --required
AND service_name = '{{ service_name }}' --required
;
Lifecycle Methods​
EXEC variables use wire (API) names.
- change_password
- copy_restore
- import
- request
- restore
Change the database password. Changes the password of the database user and returns the task. Available when changePassword is true in the database capabilities.
EXEC ovh.hosting_web.databases.change_password
@name='{{ name }}' --required,
@serviceName='{{ serviceName }}' --required
@@json=
'{
"password": "{{ password }}"
}'
;
Restore a database copy. Restores a copy into the database and returns the task. Set flushDatabase to true to empty the database first.
EXEC ovh.hosting_web.databases.copy_restore
@name='{{ name }}' --required,
@serviceName='{{ serviceName }}' --required
@@json=
'{
"copyId": "{{ copyId }}",
"flushDatabase": {{ flushDatabase }}
}'
;
Import a dump. Imports a dump file uploaded with /me/documents into the database, and returns the task. Set flushDatabase to true to empty the database first.
EXEC ovh.hosting_web.databases.import
@name='{{ name }}' --required,
@serviceName='{{ serviceName }}' --required
@@json=
'{
"documentId": "{{ documentId }}",
"flushDatabase": {{ flushDatabase }},
"sendEmail": {{ sendEmail }}
}'
;
Run a database action. Runs an action on the database and returns the task. CHECK_QUOTA refreshes the space used by the database.
EXEC ovh.hosting_web.databases.request
@name='{{ name }}' --required,
@serviceName='{{ serviceName }}' --required
@@json=
'{
"action": "{{ action }}"
}'
;
Restore a database backup. Restores the database from a daily or weekly backup and returns the task. Set sendEmail to true to receive an email when it is done.
EXEC ovh.hosting_web.databases.restore
@name='{{ name }}' --required,
@serviceName='{{ serviceName }}' --required
@@json=
'{
"date": "{{ date }}",
"sendEmail": {{ sendEmail }}
}'
;