Tech Issues

Configure MySQL for Arduino through Python


Warning !

This content is not my own. It was based on my research made on this topic. So I just share how things done in-order to achieve this.Not any sample code, Because I copied everything.


  1. Install  XAMPP, open it’s control panel and start apache and mysql. and click admin button, and goto phpmyadmin and create this your relavent database to store the data and create the corresponding tables.
  2. Install Python 2.7, and install “pyserial“, “MYSQLdb” libraries.
    1. Install “pyserial“, you can download it from Download the “.exe” file and just run it.
    2. Install “MYSQLdb“, you can download it from Download the “.exe” file and just run it
    3. Then create the require python program to write to database.  for this you need to add two statements “import serial” and “import MysqlDb”.
  3. Install Arduino, and Write the code You want to operate. and to read values form sensor , print the data using “Serial.Println(readData);” this will acquired by the relevant python file.


In some cases if mysqlDb is not figured out by the python include the following line.It is because of two reasons, any other installation of python related products such as anaconda etc, or you tried the stuff using pip installer(for this you may also have to set path variable) .

import sys
sys.path.insert(0, u'/…/…/…/python2.7/site-packages')

References :

  4. ( this is not my code, I actually referred this code for my project, hope this will help you)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s