Sq l Python Intro
description
Transcript of Sq l Python Intro
![Page 1: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/1.jpg)
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](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/2.jpg)
Step 2 : If not, install it :
![Page 3: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/3.jpg)
![Page 4: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/4.jpg)
![Page 5: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/5.jpg)
Step 3: Check if it is installed or not.
![Page 6: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/6.jpg)
![Page 7: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/7.jpg)
Step 4: Open MySQL .
Step 5: Check the database to which you want to connect to.
![Page 8: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/8.jpg)
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](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/9.jpg)
![Page 10: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/10.jpg)
Step 7: Run the file.
Check the database. You will find there.
![Page 11: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/11.jpg)
![Page 12: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/12.jpg)
Step 8: (i) Insert the data ( one column) in the table.
![Page 13: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/13.jpg)
(ii) Insert the data( all columns) in the table.
![Page 14: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/14.jpg)
![Page 15: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/15.jpg)
Step 9. Update operation :
![Page 16: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/16.jpg)
Step 10.. Select operation: Retrieve the data .
![Page 17: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/17.jpg)
Step 11.. Select operation: Retrieve few columns .
![Page 18: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/18.jpg)
Step 12.. Delete operation .
![Page 19: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/19.jpg)
Step 13.. Drop Table; .
![Page 20: Sq l Python Intro](https://reader033.fdocuments.in/reader033/viewer/2022042517/56d6c07b1a28ab30169a93c4/html5/thumbnails/20.jpg)