MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / databases

Function databases

web/pgadmin/tools/schema_diff/__init__.py:415–449  ·  view source on GitHub ↗

This function will return the list of databases for the specified server id.

(sid)

Source from the content-addressed store, hash-verified

413)
414@pga_login_required
415def databases(sid):
416 """
417 This function will return the list of databases for the specified
418 server id.
419 """
420 res = []
421 try:
422 view = SchemaDiffRegistry.get_node_view('database')
423
424 server = get_server_access(sid)
425 if server is None:
426 return make_json_response(
427 status=410, success=0,
428 errormsg=gettext(
429 "Could not find the required server.")
430 )
431 response = view.nodes(gid=server.servergroup_id, sid=sid,
432 is_schema_diff=True)
433 databases = json.loads(response.data)['data']
434 for db in databases:
435 res.append({
436 "value": db['_id'],
437 "label": db['label'],
438 "_id": db['_id'],
439 "connected": db['connected'],
440 "allowConn": db['allowConn'],
441 "image": db['icon'],
442 "canDisconn": db['canDisconn'],
443 "is_maintenance_db": db['label'] == server.maintenance_db
444 })
445
446 except Exception as e:
447 app.logger.exception(e)
448
449 return make_json_response(data=res)
450
451
452@blueprint.route(

Callers

nothing calls this directly

Calls 5

make_json_responseFunction · 0.90
gettextFunction · 0.85
get_node_viewMethod · 0.80
appendMethod · 0.80
nodesMethod · 0.45

Tested by

no test coverage detected