Advanced search FAQ Register Login

It is currently Sun Feb 18, 2018 6:56 pm


Postby Paul Vermeeren » Tue Sep 15, 2015 7:08 pm


I am trying for a couple of days now but I can't figure out how to connect via python to my MySQL database.

My plan is to connect from a website to the raspberry pi and control the wheels.
I am trying to control the speed of the wheels via a MySQL database.

The last thing I tried is:
(I have more things imported but this is the only thing for MySQL.

Code: Select all

import MySQLdb

conn = MySQLdb.connect(database="XX",host="XX",user="XX",password="XX")

cur = conn.cursor()

cur.execute("SELECT * FROM XX")
for row in cur.fetchall() :

Paul Vermeeren

Posts: 8

Joined: Sun Sep 06, 2015 3:38 pm

Postby Jake » Thu Sep 17, 2015 2:12 pm

Hi Paul,

Have you installed the MySQLdb library?

sudo apt-get install python-mysqldb

Good resource on connecting MySQL via Python ... -in-python

-- Jake


User avatar

Posts: 1397

Joined: Thu Aug 27, 2015 3:57 pm

Forum Administrator & Technical Support

Postby Aikidokajeff » Thu Sep 17, 2015 3:47 pm

Hi Paul,

Are you able to connect to MySQL via the command line and execute your queries successfully?



Posts: 8

Joined: Thu Aug 27, 2015 2:32 pm

Postby Paul Vermeeren » Fri Sep 18, 2015 2:42 pm


I'm not sure if I tried via the command line but I think that it also did not work.

I had already tried that post.
But the error that most occurred was about the logging in part.

So I gave up and got it working via a text file on my website and outputted the value with PHP and then read it from the website with python.
That way is a little more complex but I got it working eventually.


Paul Vermeeren

Posts: 8

Joined: Sun Sep 06, 2015 3:38 pm

Who is online

Users browsing this forum: No registered users and 1 guest

Board index

The teamDelete all board cookies • All times are UTC [ DST ]