Пример #1
0
    def delete_contact(cid):
        try:
            connection = DbUtil.get_connection()
            cursor = connection.cursor()
            cursor.execute("delete from contact where cid = %s ", cid)
            connection.commit()

        except pymysql.DatabaseError as error:
            print("While deleting data ...")
            print('Exception number: {}, value {!r}'.format(
                error.args[0], error))
        finally:
            DbUtil.close_connection(connection)
            DbUtil.close_cursor(cursor)
    def med_module(self, med):
        try:
            connection = DbUtil.get_connection()
            with connection.cursor() as cursor:
                cursor.execute(
                    "update pms set med = %s ,quant = %s where pid = %s", med)
            connection.commit()

        except pymysql.MySQLError as error:
            print("While inserting Data ...")
            print('Exception number: {}, value {!r}'.format(
                error.args[0], error))
        finally:
            DbUtil.close_connection(connection)
            DbUtil.close_cursor(cursor)
 def update_patient(self, contact):
     try:
         conn = DbUtil.get_connection()
         cursor = conn.cursor()
         cursor.execute(
             "update pms set name=%s,phone=%s,payment=%s,prob=%s,ward=%s,doc=%s  where pid = %s",
             contact)
         conn.commit()
     except pymysql.DatabaseError as error:
         print("While updating ... ")
         print('Exception number: {}, value {!r}'.format(
             error.args[0], error))
     finally:
         DbUtil.close_connection(conn)
         DbUtil.close_cursor(cursor)
    def user_delete(user):
        try:
            connection = DbUtil.get_connection()
            cursor = connection.cursor()
            print("User is going to delete with id ", user.i_d)
            cursor.execute("delete from login where id = %s ", str(user.i_d))
            connection.commit()

        except pymysql.DatabaseError as error:
            print("While deleting data ...")
            print('Exception number: {}, value {!r}'.format(
                error.args[0], error))
        finally:
            DbUtil.close_connection(connection)
            DbUtil.close_cursor(cursor)
 def get_all_docs(self):
     try:
         connection = DbUtil.get_connection()
         with connection.cursor() as cursor:
             cursor.execute("select name,dept,availabity from doc")
             rows = cursor.fetchall()
             doctor = self.get_list_data3(rows)
             return doctor
     except Exception as error:
         print("While retrieving data ... ")
         print('Exception number: {}, value {!r}'.format(
             error.args[0], error))
     finally:
         if connection:
             DbUtil.close_connection(connection)
             DbUtil.close_cursor(cursor)
    def doc_module(self, new_doc):
        try:
            connection = DbUtil.get_connection()
            with connection.cursor() as cursor:
                cursor.execute(
                    "insert into doc(name,dept,availabity) values(%s,%s,%s)",
                    (new_doc.name, new_doc.dept, new_doc.availabity))
            connection.commit()

        except pymysql.MySQLError as error:
            print("While inserting Data ...")
            print('Exception number: {}, value {!r}'.format(
                error.args[0], error))
        finally:
            DbUtil.close_connection(connection)
            DbUtil.close_cursor(cursor)
 def get_all_meds(self):
     try:
         connection = DbUtil.get_connection()
         with connection.cursor() as cursor:
             cursor.execute("select pid,name,doc,med,quant from pms")
             rows = cursor.fetchall()
             med_p = self.get_list_data4(rows)
             return med_p
     except Exception as error:
         print("While retrieving data ... ")
         print('Exception number: {}, value {!r}'.format(
             error.args[0], error))
     finally:
         if connection:
             DbUtil.close_connection(connection)
             DbUtil.close_cursor(cursor)
Пример #8
0
    def user_update(self, contact):
        try:
            conn = DbUtil.get_connection()
            cursor = conn.cursor()
            cursor.execute(
                "update new_student set name=%s,semister=%s,dept=%s,contact=%s where usn = %s",
                contact)
            conn.commit()

        except pymysql.DatabaseError as error:
            print("While updating ... ")
            print('Exception number: {}, value {!r}'.format(
                error.args[0], error))
        finally:
            DbUtil.close_connection(conn)
            DbUtil.close_cursor(cursor)
 def get_all_logins(self):
     try:
         connection = DbUtil.get_connection()
         with connection.cursor() as cursor:
             cursor.execute("select id,name,username,password from login")
             rows = cursor.fetchall()
             login = self.get_list_data5(rows)
             return login
     except Exception as error:
         print("While retrieving data ... ")
         print('Exception number: {}, value {!r}'.format(
             error.args[0], error))
     finally:
         if connection:
             DbUtil.close_connection(connection)
             DbUtil.close_cursor(cursor)
    def login_module(self, new_log):
        try:
            connection = DbUtil.get_connection()
            with connection.cursor() as cursor:
                cursor.execute(
                    "insert into login(id,name,username,password) values(%s,%s,%s,%s)",
                    (new_log.i_d, new_log.name, new_log.un, new_log.pwd))
            connection.commit()

        except pymysql.MySQLError as error:
            print("While inserting Data ...")
            print('Exception number: {}, value {!r}'.format(
                error.args[0], error))
        finally:
            DbUtil.close_connection(connection)
            DbUtil.close_cursor(cursor)
Пример #11
0
    def add_result(self, new_result):
        try:
            connection = DbUtil.get_connection()
            with connection.cursor() as cursor:
                cursor.execute(
                    "insert into result(name,usn,subject_code,subject_name,marks,result) values(%s,%s,%s,%s,%s,%s)",
                    (new_result.name, new_result.usn, new_result.subc,
                     new_result.subn, new_result.marks, new_result.res))
            connection.commit()

        except pymysql.MySQLError as error:
            print("While inserting Data ...")
            print('Exception number: {}, value {!r}'.format(
                error.args[0], error))
        finally:
            DbUtil.close_connection(connection)
            DbUtil.close_cursor(cursor)
 def search_reports(self, search_str):
     try:
         connection = DbUtil.get_connection()
         with connection.cursor() as cursor:
             cursor.execute(
                 "select pid,name,prob,doc,tests,test_result,test_date from pms where pid like %s ",
                 ('%' + search_str + '%'))
             rows = cursor.fetchall()
             Reports = self.get_list_data2(rows)
             return Reports
     except Exception as error:
         print("While searching Data ...")
         print('Exception number: {}, value {!r}'.format(
             error.args[0], error))
     finally:
         DbUtil.close_connection(connection)
         DbUtil.close_cursor(cursor)
Пример #13
0
 def search_usn(self, search_str):
     try:
         connection = DbUtil.get_connection()
         with connection.cursor() as cursor:
             cursor.execute(
                 "select name,usn,subject_code,subject_name,marks,result from result where usn like %s ",
                 ('%' + search_str + '%'))
             rows = cursor.fetchall()
             contacts = self.get_list_data1(rows)
             return contacts
     except Exception as error:
         print("While searching Data ...")
         print('Exception number: {}, value {!r}'.format(
             error.args[0], error))
     finally:
         DbUtil.close_connection(connection)
         DbUtil.close_cursor(cursor)
Пример #14
0
 def get_all_contacts(self):
     try:
         connection = DbUtil.get_connection()
         with connection.cursor() as cursor:
             cursor.execute(
                 "select name,usn,semister,dept,contact from new_student")
             rows = cursor.fetchall()
             contacts = self.get_list_data(rows)
             return contacts
     except Exception as error:
         print("While retrieving data ... ")
         print('Exception number: {}, value {!r}'.format(
             error.args[0], error))
     finally:
         if connection:
             DbUtil.close_connection(connection)
             DbUtil.close_cursor(cursor)
Пример #15
0
    def add_student(self, new_contact):
        try:
            connection = DbUtil.get_connection()
            with connection.cursor() as cursor:
                cursor.execute(
                    "insert into new_student(name,usn,semister,dept,contact) values(%s,%s,%s,%s,%s)",
                    (new_contact.name, new_contact.usn, new_contact.sem,
                     new_contact.dept, new_contact.numb))
            connection.commit()

        except pymysql.MySQLError as error:
            print("While inserting Data ...")
            print('Exception number: {}, value {!r}'.format(
                error.args[0], error))
        finally:
            DbUtil.close_connection(connection)
            DbUtil.close_cursor(cursor)
 def search_patient(self, search_str):
     try:
         connection = DbUtil.get_connection()
         with connection.cursor() as cursor:
             cursor.execute(
                 "select pid,name,phone,payment,prob,ward,doc,doa from pms where pid like %s ",
                 ('%' + search_str + '%'))
             rows = cursor.fetchall()
             Patients = self.get_list_data(rows)
             return Patients
     except Exception as error:
         print("While searching Data ...")
         print('Exception number: {}, value {!r}'.format(
             error.args[0], error))
     finally:
         DbUtil.close_connection(connection)
         DbUtil.close_cursor(cursor)
 def get_all_patients(self):
     try:
         connection = DbUtil.get_connection()
         with connection.cursor() as cursor:
             cursor.execute(
                 "select pid,name,phone,payment,prob,ward,doc,doa from pms")
             rows = cursor.fetchall()
             Patients = self.get_list_data(rows)
             return Patients
     except Exception as error:
         print("While retrieving data ... ")
         print('Exception number: {}, value {!r}'.format(
             error.args[0], error))
     finally:
         if connection:
             DbUtil.close_connection(connection)
             DbUtil.close_cursor(cursor)
 def search_doc(self, search_str):
     try:
         connection = DbUtil.get_connection()
         with connection.cursor() as cursor:
             cursor.execute(
                 "select name,dept,availabity from doc where name like %s ",
                 ('%' + search_str + '%'))
             rows = cursor.fetchall()
             doctor = self.get_list_data3(rows)
             return doctor
     except Exception as error:
         print("While searching Data ...")
         print('Exception number: {}, value {!r}'.format(
             error.args[0], error))
     finally:
         DbUtil.close_connection(connection)
         DbUtil.close_cursor(cursor)
 def search_med(self, search_str):
     try:
         connection = DbUtil.get_connection()
         with connection.cursor() as cursor:
             cursor.execute(
                 "select  pid,name,doc,med,quant from pms where pid like %s ",
                 ('%' + search_str + '%'))
             rows = cursor.fetchall()
             med_p = self.get_list_data4(rows)
             return med_p
     except Exception as error:
         print("While searching Data ...")
         print('Exception number: {}, value {!r}'.format(
             error.args[0], error))
     finally:
         DbUtil.close_connection(connection)
         DbUtil.close_cursor(cursor)
 def get_all_reports(self):
     try:
         connection = DbUtil.get_connection()
         with connection.cursor() as cursor:
             cursor.execute(
                 "select pid,name,prob,doc,tests,test_result,test_date from pms"
             )
             rows = cursor.fetchall()
             test = self.get_list_data2(rows)
             return test
     except Exception as error:
         print("While retrieving data ... ")
         print('Exception number: {}, value {!r}'.format(
             error.args[0], error))
     finally:
         if connection:
             DbUtil.close_connection(connection)
             DbUtil.close_cursor(cursor)
Пример #21
0
    def get_all_res(self, search_str):
        try:

            conn = DbUtil.get_connection()
            cursor = conn.cursor()
            cursor.execute(
                "select name,usn,sum((marks*10)/600) from result where usn = %s",
                ('%' + search_str + '%'))
            contact = res(*cursor.fetchone())
            contacts = self.get_list_data2(contact)
            return contact
        except pymysql.DatabaseError as error:
            print("While getting data from DB using usn... ")
            print('Exception number: {}, value {!r}'.format(
                error.args[0], error))
        finally:
            DbUtil.close_connection(conn)
            DbUtil.close_cursor(cursor)
    def add_patient(self, new_patient):
        try:
            connection = DbUtil.get_connection()
            with connection.cursor() as cursor:
                cursor.execute(
                    "insert into pms(pid,name,phone,payment,prob,ward,doc,doa) values(%s,%s,%s,%s,%s,%s,%s,%s)",
                    (new_patient.pid, new_patient.name, new_patient.phone,
                     new_patient.payment, new_patient.problem,
                     new_patient.ward, new_patient.docname, new_patient.date))
            connection.commit()

        except pymysql.MySQLError as error:
            print("While inserting Data ...")
            print('Exception number: {}, value {!r}'.format(
                error.args[0], error))
        finally:
            DbUtil.close_connection(connection)
            DbUtil.close_cursor(cursor)