Exemple #1
0
 def updaterecord(self):
     input_col_name = raw_input("enter  colmn name")
     set_col_name = raw_input("enter set colmn")
     changed_col_name = input("enter id which you want to modify")
     if ("employeeName" == input_col_name):
         cursor.execute(
             """update employee1 set employeeName=%s where employeeId=%s """,
             (set_col_name, changed_col_name))
         db.commit()
     elif ("typeofEmployee" == input_col_name):
         cursor.execute(
             """ update employee1 set typeofEmployee=%s where employeeId=%s""",
             (set_col_name, changed_col_name))
         db.commit()
     elif ("telephoneno" == input_col_name):
         cursor.execute(
             """ update employee1 set telephoneno=%s where employeeId=%s""",
             (set_col_name, changed_col_name))
         db.commit()
     elif ("skilllset" == input_col_name):
         cursor.execute(
             """ update employee1 set skillset=%s where employeeId=%s""",
             (set_col_name, changed_col_name))
         db.commit()
     elif ("yearsofExperience" == input_col_name):
         cursor.execute(
             """ update employee1 set yearsofExperience=%s where employeeId=%s""",
             (set_col_name, changed_col_name))
         db.commit()
     else:
         print("invalid input")
Exemple #2
0
    def recuperar_arestas(self):
        conexao = Conexao().criar_conexao()
        cursor = conexao.cursor()

        sql = "select v1.id, v1.longitude, v1.latitude, v2.id, v2.longitude, v2.latitude, e.distancia from estradas e, vertices v1, vertices v2 where e.origem = v1.id and e.destino = v2.id limit 1000"
        cursor.execute(sql)

        arestasbd = cursor.fetchall()
        arestas = []

        self.encerrar_conexao(conexao)

        for a in arestasbd:
            vertice_origem = Vertice(a[0], a[1], a[2])
            vertice_destino = Vertice(a[3], a[4], a[5])
            aresta = Aresta(vertice_origem, vertice_destino, a[6])
            arestas.append(aresta)
        return arestas
Exemple #3
0
    def recuperar_pontos(self):
        conexao = Conexao().criar_conexao()
        cursor = conexao.cursor()
        day = 3
        sql = "select id, id_taxista, longitude, latitude from taxistas where extract(day from hora) = {} limit 1000".format(
            day)

        cursor.execute(sql)

        pontosbd = cursor.fetchall()
        pontos = []

        self.encerrar_conexao(conexao)

        for p in pontosbd:
            ponto = Ponto(p[0], p[1], p[2], p[3])
            pontos.append(ponto)

        return pontos
Exemple #4
0
    def viewall(self):
        n = int(input("select your choice"))
        if n == 1:
            cursor.execute("""select * from employee1""")
        if n == 2:
            cursor.execute("""select * from consultant""")
        if n == 3:
            cursor.execute("""select * from project""")
        print(cursor.fetchall())
        db.commit()

        pass  #Database code to view all employees
Exemple #5
0
import sys
import MySQLdb
from gi.overrides.keysyms import cursor, Begin
from unicodedata import numeric

# Open database connection
db = MySQLdb.connect("localhost", "root", "admin", "Sample")

# prepare a cursor object using cursor() method
cursor = db.cursor()
'''
cursor.execute(""" create table employee1(
employeeId mediumint(5)  not null auto_increment primary key,
employeeName nvarchar(20),
typeofEmployee nvarchar(1),
telephoneno numeric(10),
skillset nvarchar(50),
yearsofExperience numeric(3),
basicPay numeric(5,2),
allowence numeric(5,2),
salary numeric(5,2),check(typeofEmployee='P' or typeofEmployee='c'))
""")'''
#cursor.execute(""" alter table employee1  auto_increment=1000""")
Exemple #6
0
 def viewbyid(self):
     viewId = input("enter id for view")
     cursor.execute("select * from employee1 where employeeId=%d" % viewId)
     print(cursor.fetchall())
     db.commit()
     pass  #Database code to view employee details by id
Exemple #7
0
 def deleterecord(self):
     deleterec = raw_input("enter rec u want to delt")
     cursor.execute("""delete from employee1 where employeeId=%s""" %
                    deleterec)
     db.commit()
Exemple #8
0
    def insertrecord(self):

        employeeName = raw_input("enter employee name")
        typeofEmployee = raw_input("enter type of employee")
        telephoneno = input("enter telephone number")
        skillset = raw_input("enter skillset")
        yearsofExperience = input("enter yearsofExprience")
        noofHrs = input("enter noofhrs")
        consultantfee = input("enter consultant fee")
        if skillset == 'jee':
            payRateprHr = 500
        elif skillset == 'ms':
            payRateprHr = 350
        else:
            payRateprHr = 250

        probj = Project()
        pobj = PermanentEmployee(employeeName, typeofEmployee, telephoneno,
                                 skillset, yearsofExperience)
        cobj = Consultant(employeeName, typeofEmployee, telephoneno, skillset,
                          noofHrs)
        basicPay = pobj.basicPay
        salary = NONE
        if typeofEmployee == 'p':
            allowence = pobj.calculatesalary()
            salary = basicPay + allowence
            print("permanent employee salary is:%d" % salary)
            if pobj.validatetelephoneno(
            ) and pobj.validatetypeofEmployee() is True:
                s = """ insert into employee1(employeeName,typeofEmployee,telephoneno,skillset,yearsofExperience,basicPay,allowence,salary)
                values('%s','%s','%s','%s','%s','%s','%s','%s')""" % (
                    employeeName, typeofEmployee, telephoneno, skillset,
                    yearsofExperience, basicPay, allowence, salary)

                cursor.execute(s)
                db.commit()
                cursor.execute(
                    """select employeeId from employee1 where employeeName=%s and telephoneno=%s""",
                    (employeeName, telephoneno))
                employeeId = cursor.fetchall()

                if (probj.allocateproject(pobj) is True):
                    projectId = probj.getprojectId()
                    projectTechnology = skillset
                    cursor.callproc('prj',
                                    [projectId, employeeId, projectTechnology])
                    db.commit()

        elif typeofEmployee == 'c':
            allowence = cobj.calculatesalary()
            salary = allowence
            if cobj.validatetelephoneno() is True:
                s = """ insert into employee1(employeeName,typeofEmployee,telephoneno,skillset,yearsofExperience,basicPay,allowence,salary)
                values('%s','%s','%s','%s','%s','%s','%s','%s')""" % (
                    employeeName, typeofEmployee, telephoneno, skillset,
                    yearsofExperience, basicPay, allowence, salary)
                cursor.execute(s)
                db.commit()
                print("consultant salry is:%d" % salary)

                cursor.execute(
                    """select employeeId from employee1 where employeeName=%s and telephoneno=%s""",
                    (employeeName, telephoneno))
                employeeId = cursor.fetchall()

                cursor.callproc(
                    'cons', [employeeId, noofHrs, payRateprHr, consultantfee])
                if (probj.allocateproject(pobj) is True):
                    projectId = probj.getprojectId()
                    projectTechnology = skillset
                    cursor.callproc('prj',
                                    [projectId, employeeId, projectTechnology])
                    db.commit()
        else:
            print("invalid type of employee")