def delete_server(host=""): databases = DatabaseContainer.get_databases(host=host) shortnames = [list(database.keys())[0] for database in databases] DatabaseContainer.delete(shortnames) BindContainer.delete(shortnames) DatabaseContainer.UNIQUE_HOSTS.remove(host) update() return True
def delete_database(shortname="", host=""): DatabaseContainer.delete([shortname]) BindContainer.delete([shortname]) if len(DatabaseContainer.get_databases(host=host)) <= 0: DatabaseContainer.UNIQUE_HOSTS.remove(host) return True update() return False
def decorated_function(host, shortname, table_name=None, section=None): if BindContainer.get(shortname): if not check_connection(DatabaseContainer.get(shortname)): BindContainer.delete(shortname) else: if table_name == None: return f(host, shortname) return f(host, shortname, table_name) url = url_for("blueprint.database_connect", host=host, shortname=shortname) return make_response( render_template("database/error.html", host=host, url=url), 200)
def decorated_function(*args, **kwargs): if not DatabaseContainer.get(kwargs["shortname"]): abort(404) if BindContainer.get(kwargs["shortname"]): if not check_connection(DatabaseContainer.get( kwargs["shortname"])): BindContainer.delete(kwargs["shortname"]) else: return f(*args, **kwargs) url = url_for("blueprint.database_connect", host=kwargs["host"], shortname=kwargs["shortname"]) return make_response( render_template("database/error.html", host=kwargs["host"], url=url), 200)
def database_view_operations(host, shortname): error = False c = request.args.get("c") act_db_properties = DatabaseContainer.get(shortname) form = DatabaseEditForm(request.form) if c is not None: if COMMANDS[c](host=host, shortname=shortname): return redirect( url_for("blueprint.server_view_databases", host=host)) else: return redirect('/') if request.method == 'POST': if form.validate(): if check_connection(form.data): DatabaseContainer.add(form.data) DatabaseContainer.delete([shortname]) BindContainer.delete([shortname]) BindContainer.add(form.shortname.data) update() return redirect( url_for("blueprint.database_view_operations", host=host, shortname=form.shortname.data)) else: error = "Unable connect to database." else: if len(form.shortname.errors) > 0: error = "Shortname already exists. Please specify another one." if len(form.database.errors) > 0: error = "Specifed database already exists." else: error = "Please provide correct data." return make_response( render_template('database/operations.html', host=host, form=form, error=error, act_db_properties=act_db_properties), 200)
def database_disconnect(host, shortname): BindContainer.delete([shortname]) return redirect(url_for('blueprint.server_view_info', host=host))