示例#1
0
 def getCustomers(self):
     if self.__connection == None:
         return False
     customers = []
     cursor = self.__connection.cursor(dictionary=True)
     query = ('SELECT * FROM Customers')
     print(query)
     cursor.execute(query)
     result = cursor.fetchall()
     for row in result:
         customer = Customer()
         customer.customerID = row['CustomerID']
         customer.title = row['Title']
         customer.givenNames = row['GivenNames']
         customer.lastName = row['LastName']
         customers.append(customer)
     return customers
示例#2
0
 def getCustomer(self, customerID):
     if customerID < 0:
         return False
     if self.__connection == None:
         return False
     cursor = self.__connection.cursor(dictionary=True)
     query = ('SELECT * FROM Customers WHERE CustomerID=' + str(customerID))
     print(query)
     customer = Customer()
     cursor.execute(query, (customerID))
     result = cursor.fetchall()
     if cursor.rowcount == 1:
         customer.customerID = result[0]['CustomerID']
         customer.title = result[0]['Title']
         customer.givenNames = result[0]['GivenNames']
         customer.lastName = result[0]['LastName']
     return customer