You can use the cmd method to execute Database Manager statements. The result is a character string that can be further processed using Python.
# Reference to Python Libraries
# ----------------------------
import sys
import sdb.dbm
# To create a Database Manager session:
# ------------------------------------------------------
dbm_user_name, dbm_user_password, database_name = sys.argv [1:4]
session = sdb.dbm.DBM ('', database_name, '', dbm_user_name + ',' + dbm_user_password)
Executing the DBM command for displaying the list of all database instances. The result is a character string.
output = session.cmd ('db_enum')
dbstate = 'offline'
lastdb = ''
# The database instances are separated by line breaks.
for line in output.split ('\n'):
if not line:
continue
# Data fields are separated by tab characters.
database name, installation path, version, kernel variant,
operational state = line.split ('\t')
if name != lastdb:
# Several lines exist for each database instance,
# one for each of the following kernel variants:
# fast, slow and test.
if lastdb != '':
print lastdb, '\t', dbstate
lastdb = name
dbstate = 'offline'
# The database is in operation if one of the kernel variants
# is displayed as 'running'.
if state == 'running':
dbstate = state
print lastdb, '\t', dbstate