GUPTA MECHANICAL

IN THIS WEBSITE I CAN TELL ALL ABOUT TECH. TIPS AND TRICKS APP REVIEWS AND UNBOXINGS ALSO TECH. NEWS .............

Friday, 2 December 2022

MySQL Connectivity with Python Insert Queries class 12th

Python MySQL connectivity for class 12th
MySQL.connector with python class 12th

Hello friends, I know that it is challenging for a class 12th student to get the proper result in the computer science exam. So today I am gone to give a valuable and fascinating topic of Python that is MySQL Connectivity with Python.


Why we need MySQL Connectivity:-

As we know that in this digital world and digital India, it is essential for all to stay tuned with the technology.

So  CBSE introduces a new Programming language for class 12th student that is Python, and in practice, all the students need the program and know about the MySQL Connectivity.

MySQL Connectivity is crucial to store data and make the database for our python programs because if we do not have a proper database, then we do not get the updates in the DJANGO Web Application.

MySQL Insertion with the help of Python:-

It's effortless for the Students of class 11th that knows the insert queries of the SQL.

Firstly, we have to import the Python module by command "import MySQL.connector"



JOIN MY TELEGRAM CHANNEL FOR ALL PROJECTS SOURCE CODE AND FILES And All Doubts Abouts Python:

                            

Insertion Program of Python with MySQL.connector:-


# -*- coding: utf-8 -*- """ @author: Mohit Gupta """ import mysql.connector from mysql.connector import Error from mysql.connector import errorcode try: connection = mysql.connector.connect(host='localhost', database='try', user='classxii', password='1234') mySql_insert_query = """INSERT INTO employee (EMPId, FName, Lname, cityPrice, Salary, Desig) VALUES ('010', 'Ravi','Kumar', 'Mumbai',15000, 'Manager') """ cursor = connection.cursor() result = cursor.execute(mySql_insert_query) connection.commit() print("Record inserted successfully into Laptop table") cursor.close() except mysql.connector.Error as error: print("Failed to insert record into Laptop table {}".format(error)) finally: if (connection.is_connected()): connection.close() print("MySQL connection is closed")


Thanks for Reading this valuable article for class 12th.

If you have any doubt or query, then contact me.

No comments:

Post a Comment