Skip to main content

databases

Creates, updates, deletes, gets or lists a databases resource.

Overview​

Namedatabases
TypeResource
Idovh.hosting_web.databases

Fields​

The following fields are returned by SELECT queries:

successful operation

NameDatatypeDescription
namestringDatabase name (like mydb.mysql.db or mydb.postgres.db)
sqlperso_idintegerWhich SQLPerso this database is linked to (if any) (wire: sqlpersoId)
task_idintegerThe task ID working on this database (wire: taskId)
database_service_deprecatedbooleanWhether service database is deprecated (wire: databaseServiceDeprecated)
database_typestringDatabase service type (extra, included, optional) (wire: databaseType)
dumpsintegerThe number of available dumps associated to this database
gui_urlstringURL for the graphical user interface (wire: guiURL)
last_checkstring (date-time)Date of the last check quota (wire: lastCheck)
modestringMode of your database (besteffort, classic, module)
portintegerThe port on where to contact this database
quota_sizeobjectSpace allowed (wire: quotaSize)
quota_usedobjectSpace used (wire: quotaUsed)
serverstringYour database server name
statestringDatabase state (close, ok, readonly)
statusstringThe database status (checking, created, creating, deleting, dumping, importing, locked, optimizing, restoring, updating)
typestringType of your database (mariadb, mongodb, mysql, postgresql, redis)
userstringDatabase user name
versionstringDatabase 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_supportstringIndicates the current support state of your database version (beta, deprecated, stable) (wire: versionSupport)

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectname, service_nameGet a database. Returns the type, version, server, port, user, quota and status of the database, and the URL of its management tool.
listselectservice_namemode, name, server, type, user, x_pagination_modeList databases. Returns the names of the databases of the hosting. Filter them by mode, name, server, type or user.
createinsertservice_name, capabilitie, type, userCreate a database. Creates a MariaDB, MySQL, PostgreSQL or Redis database with its user, and returns the task. The quota applies only to extraSqlPerso databases.
deletedeletename, service_nameDelete a database. Deletes the database and returns the task. Its dumps are kept until their automatic deletion date.
change_passwordexecname, serviceName, passwordChange the database password. Changes the password of the database user and returns the task. Available when changePassword is true in the database capabilities.
copy_restoreexecname, serviceName, copyIdRestore a database copy. Restores a copy into the database and returns the task. Set flushDatabase to true to empty the database first.
importexecname, serviceName, documentIdImport 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.
requestexecname, serviceName, actionRun a database action. Runs an action on the database and returns the task. CHECK_QUOTA refreshes the space used by the database.
restoreexecname, serviceName, dateRestore 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.

NameDatatypeDescription
api_hoststringThe 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"}})
namestringDatabase name (like mydb.mysql.db or mydb.postgres.db)
serviceNamestringThe internal name of your hosting
service_namestringThe internal name of your hosting (wire: serviceName)
modestringFilter the value of mode property (=)
namestringFilter the value of name property (like)
serverstringFilter the value of server property (like)
typestringFilter the value of type property (=)
userstringFilter the value of user property (like)
x_pagination_modestringSent as CachedObjectList-Pages by default so the list returns the full objects rather than their identifiers. (wire: X-Pagination-Mode)

SELECT examples​

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
;

INSERT examples​

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
;

DELETE examples​

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 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 }}"
}'
;