longnomad.blogg.se

Connecting mysql database using python on mac
Connecting mysql database using python on mac






When you are executing any command from the python command line, don’t give a space in front of the command. 1 root root 1499 mysql_connector_python-2.1.3-py2.7.egg-info # ls -l /usr/lib/python2.7/site-packages | grep -i mysqlĭrwxr-xr-x. Verify whether we got the mysql_connector_python is available under that directory as shown below. > from distutils.sysconfig import get_python_libĪs we see from the above output, on this particular system python libraries are installed under /usr/lib/python2.7/site-packages directory. Before you can use the get_python_lib function, you should also import that function as shown below.

connecting mysql database using python on mac connecting mysql database using python on mac

Next, use get_python_lib function to get the directory location where all the Python libraries will be installed. If you are completely new to Python, try this Python Hello World Example Program. In the following example, this server has Python 2.7.5 version installed. This does not have any other additional package dependencies. Next, use rpm command to install the mysql-connector-python library as shown below. In the following example, I’m using wget command to directly download the RPM file to install it on CentOS 7. You can download the mysql-connector-python from this download page. Mysql-connector-python library is available for all flavors of Linux including CentOS, Debian, Ubuntu, RedHat.

Connecting mysql database using python on mac how to#

We’ve also provided a sample python program that shows how to use the API to connect to a MySQL database and retrieve data from tables. This tutorial explains how to install mysql-connector-python library. Also, this library by itself is written in python program and does not have any other external dependencies, which makes it easier to maintain.

connecting mysql database using python on mac

The mysql-connector-python library uses APIs that are complaint with the Python Database API Specification v2.0 (PEP 249). While there are few of these libraries available, the most popular and stable is mysql-connector-python library. From a Python program, you can connect to MySQL database to access the tables and manipulate your data.įor this, you should use one of the Python MySQL Libraries.






Connecting mysql database using python on mac