Top Banner
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:
20

Sq l Python Intro

Apr 15, 2016

Download

Documents

Harshit Nimje

MySQL Python
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Sq l Python Intro

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:

Page 2: Sq l Python Intro

Step 2 : If not, install it :

Page 3: Sq l Python Intro
Page 4: Sq l Python Intro
Page 5: Sq l Python Intro

Step 3: Check if it is installed or not.

Page 6: Sq l Python Intro
Page 7: Sq l Python Intro

Step 4: Open MySQL .

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

Page 8: Sq l Python Intro

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 )

Page 9: Sq l Python Intro
Page 10: Sq l Python Intro

Step 7: Run the file.

Check the database. You will find there.

Page 11: Sq l Python Intro
Page 12: Sq l Python Intro

Step 8: (i) Insert the data ( one column) in the table.

Page 13: Sq l Python Intro

(ii) Insert the data( all columns) in the table.

Page 14: Sq l Python Intro
Page 15: Sq l Python Intro

Step 9. Update operation :

Page 16: Sq l Python Intro

Step 10.. Select operation: Retrieve the data .

Page 17: Sq l Python Intro

Step 11.. Select operation: Retrieve few columns .

Page 18: Sq l Python Intro

Step 12.. Delete operation .

Page 19: Sq l Python Intro

Step 13.. Drop Table; .

Page 20: Sq l Python Intro