0% found this document useful (0 votes)
54 views

Mysql-Python Connectivity Manual (Prepared by Archana Purwar)

The document provides steps to connect Python to MySQL. It instructs the user to install the MySQLdb package, check that it is installed, open MySQL, select a database to connect to, open a Python file to create and manipulate a table, connect to the database specifying the hostname, username, password and database name, run the Python file, insert and select data from the table, update and delete rows, and drop the table. The steps allow the user to send SQL commands from Python to perform common operations on a MySQL database table.

Uploaded by

Shubham Mishra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Mysql-Python Connectivity Manual (Prepared by Archana Purwar)

The document provides steps to connect Python to MySQL. It instructs the user to install the MySQLdb package, check that it is installed, open MySQL, select a database to connect to, open a Python file to create and manipulate a table, connect to the database specifying the hostname, username, password and database name, run the Python file, insert and select data from the table, update and delete rows, and drop the table. The steps allow the user to send SQL commands from Python to perform common operations on a MySQL database table.

Uploaded by

Shubham Mishra
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

MySQL-Python connectivity Manual

( Prepared by Archana Purwar)

Step 1: Install the package MySQLdb for coonectivity . To check whether it is already exists ,
do following:
Step 2 : If not, install it :
Step 3: Check if it is installed or not.
Step 4: Open MySQL .

Step 5: Check the database to which you want to connect to.


Step 6: Open a new file to create a table through python script.

# Open database connection // to find user name type at mysql> select user();

# to find host name type at cmd> hostname

db = MySQLdb.connect(hostname, MYSQL username, MYSQL Password, databasename )


Step 7: Run the file.

Check the database. You will find there.


Step 8: (i) Insert the data ( one column) in the table.
(ii) Insert the data( all columns) in the table.
Step 9. Update operation :
Step 10.. Select operation: Retrieve the data .
Step 11.. Select operation: Retrieve few columns .
Step 12.. Delete operation .
Step 13.. Drop Table; .

You might also like