Python Program on Database Connection
Python course with 57 real-time projects - Learn Python
Program 1
import MySQLdb from MySQLdb import * try: con=MySQLdb.Connect(host="localhost",user="root",password="root",database="dataflair") print("Connection Success....") sql="insert into employee values(115,'hari','IT',8000)" cur=con.cursor() cur.execute(sql) con.commit() print("Record Inserted......",cur.rowcount) except Exception as msg: print(msg) finally: con.close() print("Connection close....")
Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google
HOW TO IMPORT MYSQLdb pls help sir