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

Function get_data

web/pgadmin/dashboard/__init__.py:321–357  ·  view source on GitHub ↗

Generic function to get server stats based on an SQL template Args: sid: The server ID did: The database ID template: The SQL template name check_long_running_query: Returns:

(sid, did, template, check_long_running_query=False,
             only_data=False)

Source from the content-addressed store, hash-verified

319
320
321def get_data(sid, did, template, check_long_running_query=False,
322 only_data=False):
323 """
324 Generic function to get server stats based on an SQL template
325 Args:
326 sid: The server ID
327 did: The database ID
328 template: The SQL template name
329 check_long_running_query:
330
331 Returns:
332
333 """
334 # Allow no server ID to be specified (so we can generate a route in JS)
335 # but throw an error if it's actually called.
336 if not sid:
337 return internal_server_error(errormsg=ERROR_SERVER_ID_NOT_SPECIFIED)
338
339 sql = render_template(
340 "/".join([g.template_path, template]), did=did
341 )
342 status, res = g.conn.execute_dict(sql)
343
344 if not status:
345 return internal_server_error(errormsg=res)
346
347 # Check the long running query status and set the row type.
348 if check_long_running_query:
349 get_long_running_query_status(res['rows'])
350
351 if only_data:
352 return res['rows']
353
354 return ajax_response(
355 response=res['rows'],
356 status=200
357 )
358
359
360def get_long_running_query_status(activities):

Callers 4

activityFunction · 0.70
locksFunction · 0.70
preparedFunction · 0.70
configFunction · 0.70

Calls 4

internal_server_errorFunction · 0.90
joinMethod · 0.80
execute_dictMethod · 0.45

Tested by

no test coverage detected