python database connectivity

0

Python PDBC with OOPs Part – 3

Program 1 # PDBC with OOPS import MySQLdb class EmployeeDatabase: # Connection def __init__(self): self.con=MySQLdb.connect(host=’localhost’,user=’root’,password=’root’,database=’college’) #print(“Connection success”) # Insert record def insertdata(self,name,dept,salary,gender,city): try: sql=”insert into employee values(%d, ‘%s’,’%s’,%d,’%s’,’%s’)” self.cur=self.con.cursor() value=(self.maxid,name,dept,salary,gender,city) n=self.cur.execute(sql %value) self.con.commit() print(“Record...

0

How to Execute Parameterized Query in Python PDBC

Program 1 # Program for PDBC import MySQLdb try: con=MySQLdb.connect(host=’localhost’,user=’root’,password=’root’,database=’DataFlair’) print(“Data Base connected”) eno=int(input(“Enter Employee No:”)) name=input(“Enter Employee Name:”) mobile=int(input(“Enter Mobile No:”)) age=int(input(“Enter Employee age:”)) sql=”insert into employee values(%d,’%s’,%d,%d)” values=(eno,name,mobile,age) cur=con.cursor() n=cur.execute() con.commit() print(“Record...

0

DELETE and UPDATE Command in Python PDBC

Program 1 # Program for PDBC Delete Data by id import MySQLdb try: con=MySQLdb.connect(host=’localhost’,user=’root’,password=’root’,database=’DataFlair’) print(“Data Base connected”) empid=int(input(“Enter employee id for delete: “)) sql=”delete from employee where eid={}” sql=sql.format(empid) cur=con.cursor() n=0 n=cur.execute(sql) con.commit() if(n==0):...

0

Python Program on GUI Applications with PDBC

In the realm of practical Python applications, we turn our focus to the development of Graphical User Interface (GUI) applications integrated with Python Database Connection. This endeavor presents an exciting opportunity for developers to...

0

How to Auto Generate Code in Python OOPS with PDBC

In the realm of Python programming, our attention now converges on a crucial aspect—auto-generating code within Object-Oriented Programming (OOPS) frameworks, coupled with Python Database Connection Part-2 (PDBC). This topic bridges the gap between efficient...