Tracking databasesΒΆ

Dsynq can track data in databases. Currently it supports the following database management systems.

  • MySQL
  • PostgreSQL (including PostGIS)

Note

In this tutorial the examples make use of a local MySQL server which has user root without a password. You may need to change the example mysql commands to be able to connect to your MySQL server.

First, make database hello_dsynq_db and table item in it.

> mysql -u root -e "CREATE DATABASE hello_dsynq_db"
> mysql -u root hello_dsynq_db -e "CREATE TABLE item (id INT NOT NULL AUTO_INCREMENT, code INT NOT NULL, name CHAR(30) NOT NULL, PRIMARY KEY (id));"

To enable Dsynq to connect to hello_dsynq_db, save its connection parameters to a Dsynq config. Use .dsynqconfig.yaml in the project's home directory. Git tracks it and others will be able to reuse this database config as the default in their development environment.

> cat .dsynqconfig.yaml
databases: {}
dsynq: {}
> cat > .dsynqconfig.yaml <<EOF
databases:
        hello_dsynq_db:
                engine: mysql
                host: localhost
                name: hello_dsynq_db
                password: ''
                user: root
dsynq: {}
EOF
> cat .dsynqconfig.yaml
databases:
        hello_dsynq_db:
                engine: mysql
                host: localhost
                name: hello_dsynq_db
                password: ''
                user: root
dsynq: {}

Dsynq has to have all the required information to connect to its databases. The key hello_dsynq_db in the dictionary matches the name of a child directory in data/.databases/. It also matches the name of the database (the value of the name parameter) but this is not required.

Command group dsynq delta has all the commands to work with the database data. For example, to check the status of the database connections use dsynq delta status.

> dsynq delta status
Databases:
     Databases found: 1

     1.
     Database: hello_dsynq_db
     engine: mysql
     host: localhost
     port: 3306
     name: hello_dsynq_db
     user: root
     password:

     Database deltas found: <None>
     Last applied database delta: 0.000000

For more information about how Dsynq works with databases, read Database deltas.