Installing Python MySQLdb

Get started learning Python with DataCamp's free Intro to Python tutorial. Learn Data Science by completing interactive coding challenges and watching videos by expert instructors. Start Now!

MySQLdb is an api for accessing MySQL database using python. It is built on top of MySQL C API.

MySQLdb don’t yet have support for python 3, it supports only python 2.4 – 2.7 . As a result you need to use python 2 for this tutorial. We will be using python 2.7.9, which you can download from here.

Installing MySQLdb

Before installing you must first check whether MySQLdb is already installed on your system. To test open command prompt or terminal, then start python shell and type the following code

If it throws ImportError  like this

check mysqldb installation

then you need to install MySQLdb. Otherwise you have MySQLdb installed.

If you are on windows download the MySQLdb from here and install it.

In the next post we will discuss the steps we need to take to access database.

Other Tutorials

This site generously supported by DataCamp. DataCamp offers online interactive Python Tutorials for Data Science. Join over a million other learners and get started learning Python for data science today!

Leave a Reply

Be the First to Comment!

Notify of
avatar

wpDiscuz