Page 1 of 1

Mysql python connector version and installation help

Posted: Thu Nov 10, 2016 8:40 pm
by cscuilla
Can someone please explain which version I should download from the following link for use on a rpi 3 with Jessie Lite installed.

http://dev.mysql.com/downloads/connector/python/

Also, could someone explain how to install it as well?

thanks

craig

Re: Mysql python connector version and installation help

Posted: Thu Nov 10, 2016 8:46 pm
by rpdom
cscuilla wrote:Can someone please explain which version I should download from the following link for use on a rpi 3 with Jessie Lite installed.
Probably none of them. Use the version in the Raspbian repository instead.
For Python 2:

Code: Select all

sudo apt-get update
sudo apt-get -y install python-mysql.connector
For Python 3:

Code: Select all

sudo apt-get update
sudo apt-get -y install python3-mysql.connector

Re: Mysql python connector version and installation help

Posted: Thu Nov 10, 2016 9:00 pm
by cscuilla
Thank you. Is their any documentation for this?
I am attempting to connect to a mariadb using python. using the following instructions..

https://mariadb.com/resources/blog/how- ... ms-mariadb

This was previously set up and working using Mysql and MySQLdb connector.. I don't see in the above instructions where to set the host (IP address of mariadb server).

I've installed the files you suggested, when I run the python script I receive the following error.

Code: Select all

 File "/usr/lib/python2.7/dist-packages/mysql/connector/__init__.py", line 155, in connect
    return MySQLConnection(*args, **kwargs)
TypeError: __init__() takes exactly 1 argument (5 given)

Re: Mysql python connector version and installation help

Posted: Thu Nov 10, 2016 9:16 pm
by rpdom
You set the host by including a host='xxxxx' parameter in the connect.

Using their example:

Code: Select all

mariadb_connection = mariadb.connect(user='python_user', password='some_pass', database='employees', host='mydbhost')
I just tested some code like this with one of my databases and it works.

Re: Mysql python connector version and installation help

Posted: Thu Nov 10, 2016 9:25 pm
by cscuilla
Thank you again. It's working now! You have been a great help. I spent an hour or so reading those docs on the mysql page and was hoping for an "apt-get install" solution like the one you provided.