Creating Databases

The add-db operation is used to create a database for a certain webspace. You can specify the database settings only on creation. You can create a database of one of the following types:

In this chapter:

Request Packet Structure

Response Packet Structure

Samples

 

Request Packet Structure

A request XML packet creating a database includes the add-db operation node:

<packet>
<database>
   <add-db>
   ...
   </add-db>
</database>
</packet>

 

The add-db node is presented by type DatabaseAddInputType (database_input.xsd), and its graphical representation is as follows:

Note: Use lower case for the database types. In other case the request might be incorrectly processed by the server.

Remarks

You can add multiple databases in a single packet. Add as many add-db operations as the number of databases you want to add.

<database>
   <add-db>
   ...
   </add-db>
...
   <add-db>
   ...
   </add-db>

</database>

Important: When creating request packets, put nodes and elements in the order they follow in the packet structure.

 

Response Packet Structure

The add-db node of the output XML packet is presented by type DatabaseAddDBOutputType (database_output.xsd) and structured as follows:

 

 

Samples

Adding a database

The request packet structured as follows:

<packet>
<database>

<add-db>
   <webspace-id>7</webspace-id>
   <name>MyBase</name>
   <type>mysql</type>
</add-db>

</database>
</packet>

 Request:

<packet>
<database>

<add-db>
   <result>
      <status>ok</status>
      <id>14</id>
   </result>
</add-db>

</database>
</packet>

 

If MyBase already exists, the response from the server looks as follows:

<packet>
<database>

<add-db>
<result>
      <status>error</status>
      <errcode>1007</errcode>
      <errtext>Database already exists</errtext>
</result>
</add-db>

</database>
</packet>

 

If the webspace with ID 7 was not found, the response looks as follows:

<packet>
<database>

<add-db>
<result>
      <status>error</status>
      <errcode>1015</errcode>
      <errtext>Domain does not exist</errtext>
</result>
</add-db>

</database>
</packet>
Adding multiple databases

The request packet adding mySQL and PostgreSQL databases looks as follows:

<packet>
<database>

<add-db>
   <webspace-id>3</webspace-id>
   <name>MyBase</name>
   <type>mysql</type>
</add-db>

<add-db>
   <webspace-id>3</webspace-id>
   <name>MyBase</name>
   <type>mysql</type>
</add-db>

</database>
</packet>

Response:

<packet>
<database>

<add-db>
<result>
      <status>ok</status>
      <id>14</id>
</result>
</add-db>

<add-db>
<result>
      <status>error</status>
      <errcode>1007</errcode>
      <errtext>Database already exists</errtext>
</result>
</add-db>

</database>
</packet>