Пример #1
0
 def get_all_profiles(self):
     '''
     Returns all profiles in the database
     '''
     res_names = self.database.execute("SELECT * FROM PersonTable")
     #We obtain now all profiles
     profiles = {}
     for name in res_names:
         prof = rootsmagic_profile(name[0], self.database)
         profiles[name[0]] = prof
     return profiles.values()
Пример #2
0
 def get_profile_by_ID(self, id_profile):
     '''
     Returns the profile by the input ID
     '''
     profile_id = "SELECT * FROM PersonTable WHERE PersonID=?"
     profile_cursor = self.database.execute(profile_id, (str(id_profile), ))
     #Now let's fetch the first value
     is_profile_in = profile_cursor.fetchone()
     if is_profile_in:
         return rootsmagic_profile(id_profile, self.database)
     else:
         return None
Пример #3
0
 def __init__(self, db_file):
     '''
     Construction, taking as initial parameter the location of the database
     '''
     self.database = None
     self.right_read = False
     #Open database and get it as part of the class
     self.database = sqlite3.connect(db_file)
     res_names = self.database.execute("SELECT * FROM NameTable")
     self.profiles = []
     for name in res_names:
         prof = rootsmagic_profile(name[3], name[2], name[0], name[1], self.database)
         self.profiles.append(prof)