def delete_wallet(user_id): session = Session() try: wallet = session.query(Wallets).filter_by(user_id=int(user_id)).one() except: abort(404, description="Wallet not found") session.delete(wallet) session.commit() return jsonify({"Success": "Wallet has been deleted"}), 200
def delete(self): session = Session() # result = session.query(User).filter_by(id=user_id).first() exist = auth.current_user() if exist: print("User has been deleted") if not exist: abort(500, message="User doesn't exist, cannot delete") exist = session.merge(exist) session.delete(exist) session.commit() return "User deleted", 204