Exemplo n.º 1
0
 def _pickle_log(self):
     data_to_pickle = Lfh.get_log(Lfh, "log.txt")
     pickled_data = Pkl.pickle_data(data_to_pickle)
     self.pickled_log.append(pickled_data)
     if self.display_detail_output:
         print("Input: {}".format(data_to_pickle))
         print("Pickled Data: {}".format(self.pickled_log))
Exemplo n.º 2
0
 def insert_staff(self, staff):
     """insert staff into the table"""
     count = 1
     try:
         for person in staff:
             p = Pickler.pickle_data(person)
             self._cursor.execute(
                 """INSERT INTO Staff (emp_id, 
             gender, age, sales, bmi, salary, birthday, valid)
             VALUES (?, ?, ?, ?, ?, ?, ?, ?)""",
                 (p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]))
             print(count, "Person added")
             count += 1
             self.commit()
     except sqlite3.IntegrityError:
         print('That record already exists')
     except IndexError:
         print('List index out of range')
     except sqlite3.OperationalError:
         print("Oops! This was an operational error. Try again...")
     except TypeError:
         print("Type Error")
     except ValueError:
         print("Value error")
     except IOError:
         print("IO error")
     except Error as e:
         print(e)
     finally:
         print("Finished inserting into database")
Exemplo n.º 3
0
    def _unpickle_errors(self):
        un_pickled_data = ""

        try:
            un_pickled_data = Pkl.unpickle_data(self.pickled_errors[0])
        except IndexError:
            print(Err.get_error_message(208))
        if self.display_detail_output:
            print("Unpickled Data: {}".format(un_pickled_data))
        return un_pickled_data
Exemplo n.º 4
0
 def get_staff(self):
     """get all staff from the table"""
     try:
         self._cursor.execute("SELECT * FROM Staff")
         rows = self._cursor.fetchall()
         for row in rows:
             un_pickled = Pickler.unpickle_data(row)
             print(un_pickled)
     except Error as e:
         print("An error occurred:", e)
Exemplo n.º 5
0
 def send_data_to_pickler():
     to_pickle = ErrorDict.get_error_dict('')
     pickled = Pickler.pickle_list(to_pickle)
     return pickled