def registration(username, password): try: db = DbController(os.path.join(os.getcwd(), '..', 'db.sqlite3'), 'user') id_ = db.create(username=username, password=password) return User(id_, username, password) except sqlite3.Error as e: print(e) return None
def create(title, text, owner, files): try: db = DbController(os.path.join(os.getcwd(), '..', 'db.sqlite3'), 'post') post_id = db.create(title, text, owner) db = DbController(os.path.join(os.getcwd(), '..', 'db.sqlite3'), 'p_files') post_files = [] if files: for i in files: try: id_ = db.create(i[0], post_id, i[1], i[2]) post_files.append(id_) except: continue return Post(post_id, title, text, owner, post_files) except sqlite3.Error as e: print(e) return None