Esempio n. 1
0
 def getEntity(self, paramDict):
     res_ticket = Ticket()
     query = 'SELECT TicketId, PIB, Passport, Place, RaceId, Price ' \
             'FROM Ticket ' \
             'WHERE '
     equal_substr = '{attr_name} = ?'
     counter = len(paramDict)
     args = []
     for param in paramDict:
         query += equal_substr.format(attr_name=param)
         args.append(paramDict[param])
         if counter == 1:
             query += ';'
         else:
             query += ' AND '
         counter -= 1
     connection = sqlite3.connect(self._dbname)
     result = connection.execute(query, args).fetchone()
     connection.close()
     res_ticket.ticketId = result[0]
     res_ticket.pib = result[1]
     res_ticket.passport = result[2]
     res_ticket.place = result[3]
     res_ticket.raceId = result[4]
     res_ticket.price = result[5]
     return res_ticket
Esempio n. 2
0
 def getAll(self):
     tickets = []
     query = 'SELECT TicketId, PIB, Passport, Place, RaceId, Price ' \
             'FROM Ticket'
     connection = sqlite3.connect(self._dbname)
     result = connection.execute(query).fetchall()
     for ticket in result:
         ticket = Ticket()
         ticket.ticketId = user_data[0]
         ticket.pib = user_data[1]
         ticket.passport = user_data[2]
         ticket.place = user_data[3]
         ticket.raceId = user_data[4]
         ticket.price = user_data[5]
         tickets.append(ticket)
     connection.close()
     return tickets
 def add_og_ticket(self, owner):
     ticket = Ticket("source", owner, 0)
     ticket.tid = random_word()
     ticket.price = 0
     self.pool.append(ticket)