Example #1
0
 def all():
     try:
         db = DbController(os.path.join(os.getcwd(), '..', 'db'), 'post')
         posts = db.all()
         user_list = []
         db = DbController(os.path.join(os.getcwd(), '..', 'db'), 'p_files')
         for data in posts:
             file_list = [
                 i['Id'] for i in db.all(param_name='post_id',
                                         param_value=data['Id'])
             ]
             user_list.append(
                 Post(data['Id'], data['title'], data['text'],
                      data['owner'], file_list))
         return user_list
     except sqlite3.Error as e:
         print(e)
     return None
Example #2
0
 def all_user():
     try:
         db = DbController(os.path.join(os.getcwd(), '..', 'db'), 'user')
         users = db.all()
         user_list = []
         for data in users:
             user_list.append(
                 User(data['Id'], data['username'], data['password']))
         return user_list
     except sqlite3.Error as e:
         print(e)
     return None