---
Title: XML2DB API – MySQL/MariaDB Database
Language: en-US
Canonical URL to this Markdown version of this page: [https://docs.kvik.shop/xml2db-api/mysql-mariadb-database.md](https://docs.kvik.shop/xml2db-api/mysql-mariadb-database.md)
Canonical URL to HTML version of this page (for humans): [https://docs.kvik.shop/xml2db-api/mysql-mariadb-database](https://docs.kvik.shop/xml2db-api/mysql-mariadb-database)
---

# XML2DB API – MySQL/MariaDB Database

Breadcrumb: [XML2DB API](https://docs.kvik.shop/xml2db-api.md) > [MySQL/MariaDB Database](https://docs.kvik.shop/xml2db-api/mysql-mariadb-database.md)



Automatical sending of data to a MySQL database. 
The option is provided as a shop module called XML2DB.
Records are being automatically sent after a order/user/payment creation based on the event configuration. 

## Recommended server configuration
You need MySQL or MariaDB server running on your server/VPS. Recquired configuration depends on loads (number of records written per minute), but we recommend this minimum configuration for starter:

- 2GB RAM
- 1× 1Ghz CPU
- 10 GB storage
- MySQL version >5.6 or MariaDb >10.2

If you are Czech/Slovak speaking, we recommend you the MiniVPS service from a Czech server-hosting company named vas-server.cz.


## Credentials
The shop will be accessing the MySQL database from the IP addresses bellow. These IP addresses has to be allowed in a firewall and the MySQL database itself.

- 34.241.33.32
- 52.30.167.241
- 195.47.51.177
- 63.32.139.45

kvik.shop need credentials for your MySQL/MariaDB (server domain/IP, username, password, database name) and permission to create SQL table (read, write).


## Table schema

```
CREATE TABLE `xml_to_database` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `type` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `item_id` varchar(100) NOT NULL,
  `action` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `xml` mediumtext NOT NULL,
  `timestamp` int(10) unsigned NOT NULL DEFAULT '0',
  `status` tinyint(3) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`Id`),
  KEY `type_item_id_INDEX` (`type`,`item_id`),
  KEY `status_type_timestamp_INDEX` (`status`, `type`, `timestamp`)
) DEFAULT CHARSET = utf8mb4;
```

## Column values

#### Column 'id'
Unique identifier automatically incremented.


#### Column 'type'
Contains information about the XML type. 

Can contain these values:

- 1 = XML with order information,
- 2 = XML with information about order payment.
- 3 = XML with information about user account.

#### Column 'item_id'
Contains identifier of written entity (order, user account) for reasons. This number does not have to always correspond with order number or user account. Do not consider this as a order number when processing the data, though it will be same in most cases.


#### Column 'action'
Contains information whether the record is new or an update of already existing record sent in the past. 

Can contain these values:

- 0 — new record (e.g. new order, new user),
- 2 — update of existing record.

#### Column 'xml'
XML with data of written entity.


#### Column 'timestamp'
Time when the order was written.


#### Column 'status'
Contains information for client-side which processes the data. Can contain these values:

- 0 — record should not be processed yet,
- 1 — record can be processed,
- 2 — record was already processed. Value 2 is written by the processing side, it marks down that the record has been already processed.

When you process the record, you HAVE to delete the record from the database OR update the value in status column to mark the record as processed.


## Event Configuration
By default, only new orders are sent to the database. Each order corresponds to a single SQL record in the MySQL database.

There are options that determine whether updates to these entities should be sent to the database or not.

- Order changes = (true/false) If changes are made to an order, then a new order record is sent with value 2 in action column (see columns specification below).
- User account changes = (true/false) If changes are made to user account, then a new order record is sent with value 2 in action column (see columns specification below).
- Product info in Order XML = (true/false) It is possible to append product XML subtree to all ordered products in Order XML. This feature is disabled by default. Read more about this.
- Please write us on info@kvik.shop so we can set these options.