Knowledgebase: MySQL & Databases
How to connect with Python
Posted by Pacific Host on 05 December 2011 05:42 AM

How do I connect to a MySQL database using Python? 
First, import the MySQLdb module:

import MySQLdb

Next, create a connection object:


Finally, create a cursor object:


Use the 'execute' method on the 'cursor' object to submit SQL to the database.

(0 vote(s))
Not helpful

Comments (0)