Hi…to all today i’m going to tell how to connect python with Mysql
we need a package named MySQLdb
install that package inorder to connect mysql and python.
$ sudo apt-get install python-mysqldb
Here is the code to connect to mysql
#creating connection using Mysqldb and mqsql dbname,username and password
con = MySQLdb.connect(host = “localhost”, user = “root”, passwd = “”, db = “balaji”)
#creating currsor to access to db
#Executing query using cursor
#printing the result
#closing the db connection .
Save this file with .py extension
now run the file by $ python filename.py
Thats it..enjoy the coding with python…happy times!!!