MySQL for the Internet of Things

(Steven Felgate) #1
Chapter 6 ■ Building low-Cost MysQl data nodes

MYSQL UtILItIeS: pYthON-BaSeD DataBaSe aDMINIStratION


if you are a python developer and find yourself working more and more with MysQl, especially if you
have found yourself in the role of administrator, you may want to look at MysQl utilities from oracle.
MysQl utilities is a set of python scripts and a python library for managing MysQl servers. you can
do all manner of things from copying user permissions to cloning servers to discovering differences
between two databases. see http://dev.mysql.com/downloads/utilities/ for more details.

You may also want to write complex Python scripts for manipulating your data from your sensors or IOT
data collectors. That is, you could use a Raspberry Pi as a data aggregator for preparing data for storage. You
can even use Python applications to read sensors directly from the Raspberry Pi as I demonstrated in my
book Beginning Sensor Networks with Arduino and Raspberry Pi (Apress, 2014).
For more complex examples including executing transactions, creating tables, and running complex
queries, see the coding examples section in the Connector/Python online reference manual
(http://dev.mysql.com/doc/connector-python/en/connector-python-examples.html).


Summary


This chapter introduced MySQL and gave you a crash course on how to set up a Raspberry Pi, install MySQL,
and use it. You also learned how to write data to your database server using an Arduino sketch and a Python
program on another machine (Raspberry Pi, BeagleBone Black, pcDuino, and so on).
Although it does not have nearly the sophistication of a high availability, five-nines uptime (99.999
percent) database server, the low-cost Raspberry Pi with an attached USB hard drive makes for a very
small-footprint database server that you can put just about anywhere. This is great because IOT solutions, by
nature and often by necessity, need to be small and low cost. Having to build an expensive database server is
not usually the level of investment desired.
In the next chapter, we will explore an advanced topic: high availability. More specifically, we will see
how to make our database server more reliable by providing redundancy as well as an ability to separate
reads (SELECT) and writes (INSERT, UPDATE, DELETE) across multiple database nodes.

Free download pdf