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
# !usr/bin/python
import MySQLdb
#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
cursor=con.cursor()
#Executing query using cursor
cursor.execute(“SELECT VERSION()”)
result=cursor.fetchone()
#printing the result
print result
#closing the db connection .
con.close()
Save this file with .py extension
now run the file by $ python filename.py
Thats it..enjoy the coding with python…happy times!!!
is funtionaly in android????