def show_all(self): """show all present records in database""" table = self.select_all view.record_names() for t in table: print("\t\t" + str(t[1]) + "\t\t" + str(t[2]) + "\t\t" + str(t[3]) + "\t\t" + str(t[2] * t[3] / 100))
def show_all(self): """show all present records in database""" self.model.cursor.execute('SELECT * FROM {}'.format( self.model.db_name)) table = self.model.cursor.fetchall() view.record_names() if len(table) > 0: for t in table: print( str(t[1]) + "\t\t" + str(t[2]) + "\t\t" + str(t[3]) + "\t\t\t\t" + str(t[2] * t[3] / 100))
def show_by_date(self): """show length ridden and fuel used by certain date""" date = view.enter_date(input) if mdl.check_validity_of_date(date): table = self.date(dt.datetime.strptime(date, "%d-%m-%Y")) view.record_names() for t in table: print("\t\t" + str(t[1]) + "\t\t" + str(t[2]) + "\t\t" + str(t[3]) + "\t\t" + str(t[2] * t[3] / 100)) else: view.invalid_value()
def show_by_date(self): """show length ridden and fuel used by certain date""" date = view.enter_date(input) if mdl.check_validity_of_date(date): date = self._mk_date_usable(date) self.cursor.execute( "select * from " + self.tablename + " where date = %s", (date, )) table = self.cursor.fetchall() view.record_names() view.print_table_from_sql(table) else: view.invalid_value()
def show_by_period(self): """show length ridden and fuel used by certain period (from - to)""" left, right = view.enter_period(input, input) if mdl.check_validity_of_date(left) and mdl.check_validity_of_date( right): table = self.period(dt.datetime.strptime(left, "%d-%m-%Y"), dt.datetime.strptime(right, "%d-%m-%Y")) view.record_names() for t in table: print("\t\t" + str(t[1]) + "\t\t" + str(t[2]) + "\t\t" + str(t[3]) + "\t\t" + str(t[2] * t[3] / 100)) else: view.invalid_value()
def show_by_period(self): """show length ridden and fuel used by certain period (from - to)""" left, right = view.enter_period(input, input) if mdl.check_validity_of_date(left) and mdl.check_validity_of_date( right): left = self._mk_date_usable(left) right = self._mk_date_usable(right) self.cursor.execute( "select * from " + self.tablename + " where date >= %s and date <= %s", (left, right)) table = self.cursor.fetchall() view.record_names() view.print_table_from_sql(table) else: view.invalid_value()
def show_by_date(self, input_func=input): """show length ridden and fuel used by certain date""" date = view.enter_date(input_func) if mdl.check_validity_of_date(date): date = dt.datetime.strptime(date, "%d-%m-%Y").strftime('%Y-%m-%d') print(date) self.model.cursor.execute( "SELECT * FROM {db_name} WHERE date = ?".format( db_name=self.model.db_name), (date, )) records_daily = self.model.cursor.fetchall() view.record_names() if len(records_daily) > 0: for t in records_daily: print( str(t[1]) + "\t\t" + str(t[2]) + "\t\t" + str(t[3]) + "\t\t\t\t" + str(t[2] * t[3] / 100)) else: view.invalid_value()
def show_by_period(self): """show length ridden and fuel used by certain period (from - to)""" left, right = view.enter_period(input, input) if mdl.check_validity_of_date(left) and mdl.check_validity_of_date( right): left = dt.datetime.strptime( left, "%d-%m-%Y").strftime('%Y-%m-%d %H:%M:%S') right = dt.datetime.strptime( right, "%d-%m-%Y").strftime('%Y-%m-%d %H:%M:%S') self.model.cursor.execute( "SELECT * FROM {db_name} WHERE date >= ? AND date <= ?".format( db_name=self.model.db_name), (left, right)) table = self.model.cursor.fetchall() print(table) view.record_names() if len(table) > 0: for t in table: print( str(t[1]) + "\t\t" + str(t[2]) + "\t\t" + str(t[3]) + "\t\t\t\t" + str(t[2] * t[3] / 100)) else: view.invalid_value()
def show_all(records): view.record_names() for item in records: view.print_record(item, get_used_fuel(item))
def show_all(self): """show all present records in database""" self.cursor.execute("select * from " + self.tablename) table = self.cursor.fetchall() view.record_names() view.print_table_from_sql(table)