fgTo connect to a database we must first install a special module to communicate with the database.If the database is MYSQL you must install MySQLdb module.
To do that you must type;
yum install MySQL-python
After the instalation you shoyld be able to; >>>import MySQLdb
If this thing won't give any error you can continue.
First we must import modules which we need to runour script. So;
Then we must connect to the databace and to do that;
print "Can not connect to the database"
Now we are connected to the database. Now we need to send querys to our database.
cursor.execute(""" your query """)
priint "Some error...!!!"
You had done all the things for now. So you shoul close the connection which you open.