MCPcopy Create free account
hub / github.com/SeldonIO/seldon-server / get_db_details

Function get_db_details

python/seldon/shell/cmdutils.py:9–48  ·  view source on GitHub ↗
(zk_client)

Source from the content-addressed store, hash-verified

7 return conn;
8
9def get_db_details(zk_client):
10 db_details = {}
11 dbcp_node = zk_client.get('/config/dbcp')
12 dbcp_details_json = dbcp_node[0]
13 dbcp_details = json.loads(dbcp_details_json)
14 for db_info in dbcp_details['dbs']:
15 name = db_info['name']
16 user = db_info['user']
17 passwd = db_info['password']
18 db = 'mysql'
19 jdbc = db_info['jdbc']
20 m=re.search(':\/\/(.*)[:](.*),', jdbc)
21 host = m.group(1)
22 port = int(m.group(2))
23 db_details[ name ] = {
24 "host" : host,
25 "port" : port,
26 "status" : "",
27 "error_msg" : ""
28 }
29 try:
30 conn = get_conn(user, passwd, db, host, port)
31 try:
32 cur = conn.cursor(mdb.cursors.DictCursor)
33 sql="show status like 'Threads_connected%';"
34 cur.execute(sql)
35 rows = cur.fetchall()
36 cur.close()
37 db_details[ name ]['status'] = "OK"
38 except Exception as e:
39 error_msg=str(e)
40 db_details[ name ]['status'] = "FAILED"
41 db_details[ name ]['error_msg'] = error_msg
42 finally:
43 conn.close()
44 except Exception as e:
45 error_msg=str(e)
46 db_details[ name ]['status'] = "FAILED"
47 db_details[ name ]['error_msg'] = error_msg
48 return db_details

Callers

nothing calls this directly

Calls 6

get_connFunction · 0.85
getMethod · 0.65
executeMethod · 0.65
strFunction · 0.50
searchMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected