Database Connection & Replication KB

Comparison of Databases for Data Replication: https://docs.google.com/document/d/1KR8rDzTteviE4A_Klt_-5Gp7otV4YOT9w6PvUbgJc4U/edit?usp=sharing

  • TL;DR: In terms of Replication capabilities, MySQL is probably our safest bet. Postgres/MariaDB seem to be have marginally better capabilities, but not too far from MySQL. Products like Cockroach DB would be awesome since they’re designed to natively support distribution and replication, but will be very difficult (if not impossible) to run on Raspberry Pi’s.

Connecting MySQL Server with Python:

Code for connection:

import mysql.connector cnx = mysql.connector.connect( host="127.0.0.1", port=3306, user="admin", password="password") cur = cnx.cursor() cur.execute("SELECT * FROM mainschema.coordinate") row = cur.fetchone() print(row) cnx.close()

 


Running Multiple MySQL Servers on One System (to simulate replication):

DBDeployer: Out of all of the methods tested, DBDeployer is probably the easiest way to set up replication:

  1. Install DBDeployer: Installation Wiki

    1. You’ll have to download one of the dbdeployer releases, which from what I can see, is only available for Linux/MacOS If you’re on Windows, you could potentially try using WSL.

    2. As of writing this, the third alternative to install DBDeployer (gobinaries) isn’t functioning.

  2. At this point, typing in dbdeployer in your terminal should give you the help commands required.

  3. Next, you want to install the MySQL binary tarball from here: MySQL :: Download MySQL Community Server

  4. Follow the unpacking instructions on here: Main Operations Wiki