Enterprise Application Development using ORM Architecture in Python Part-1

Master Python with 70+ Hands-on Projects and Get Job-ready - Learn Python

Program 1

class Employee:
    def setid(self,empid):
        self.empid=empid
    def getid(self):
        return self.empid
    def setname(self,empname):
        self.empname=empname
    def getname(self):
        return self.empname
    def setdept(self,empdept):
        self.empdept=empdept
    def getdept(self):
        return self.empdept
    def setsalary(self,empsalary):
        self.empsalary=empsalary
    def getsalary(self):
        return self.empsalary

 

We work very hard to provide you quality material
Could you take 15 seconds and share your happy experience on Google

courses

TechVidvan Team

TechVidvan Team provides high-quality content & courses on AI, ML, Data Science, Data Engineering, Data Analytics, programming, Python, DSA, Android, Flutter, full stack web dev, MERN, and many latest technology.

2 Responses

  1. Mirza Abdullah Baig says:

    Hello,

    Sir, I need the complete code of the ORM structure console-based.

    Thanks and regards

  2. Mirza Abdullah Baig says:

    Hellos Sir,

    I can’t get rid of this error :

    C:\PyCharm\venv\Scripts\python.exe “C:\PyCharm\dao aplication\main for testing.py”
    Enter your id :1
    Enter your name : Mirza
    Enter your salary:12345690
    Enter your dept: IT
    Connection success
    Traceback (most recent call last):
    File “C:\PyCharm\dao aplication\main for testing.py”, line 48, in
    E2.updateemployee(E1)
    File “C:\PyCharm\dao aplication\employeedao.py”, line 36, in updateemployee
    self.cur.execute(sql % value)
    ~~~~^~~~~~~
    TypeError: not enough arguments for format string

    Process finished with exit code 1

    Note my code in main.py is :

    E1=model.employee()
    eid=int(input(“Enter your id :”))
    name=input(“Enter your name :”)
    salary=int(input(“Enter your salary :”))
    dept= input(“Enter your dept :”)
    E1.seteid(id)
    E1.setname(name)
    E1.setsalary(salary)
    E1.setdept(dept)
    E2=employeedao.EmployeeDAO()
    E2.updateemployee(E1) —————————line 48

    my code in employeedao.py is :

    def updateemployee(self,E1):
    sql = “UPDATE employee SET name=’%s’, salary=’%d’, dept=’%s’ WHERE eid=%d”
    value = (E1.getname(), E1.getsalary(), E1.getdept())
    self.cur.execute(sql % value) ———————————— line 36
    self.con.comnit()

    please correct the code.

    Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *