Sunday, 30 August 2026

GRADE 12 : LAB 19 : Python MySQL connectivity

 GRADE 12 . LAB 19

 

'''Write a program to connect python with mysql using database connectivity and create the given table with values. Create a menu driven program for:


>display 1 record

>display many records

>display all records

>count the total records

>update the train no of a particular passenger

>delete data with a certain pnr

>display data of all the female passengers whose age is greater than 30


(The below is created in mysql in Database DB19)

TABLE : PASSENGER

+------------------------------------------------------+

| PNR | TNO   |    PNAME   | GENDER | AGE | TRAVELDATE |

+------------------------------------------------------+

|P001 | 13005 |R N AGARWAL |  MALE  | 45  | 2018-12-25 |

|P002 | 12015 |P TIWARY    |  MALE  | 28  | 2018-11-10 |

|P003 | 12015 |S TIWARI    | FEMALE | 22  | 2018-11-10 |

|P004 | 12030 |S K SAXENA  |  MALE  | 42  | 2018-10-12 |

|P005 | 12030 |S SAXENA    | FEMALE | 35  | 2018-10-12 |

|P006 | 12030 |P SAXENA    | FEMALE | 12  | 2018-10-12 |

|P007 | 13005 |N S SINGH   |  MALE  | 52  | 2018-05-09 |

|P008 | 12030 |J K SHARMA  |  MALE  | 65  | 2018-05-09 |

|P009 | 12030 |R SHARMA    | FEMALE | 58  | 2018-05-09 |

+------------------------------------------------------+  '''