Procedure documentationExample: Opening and Closing a Connection to the Database Manager Locate this document in the navigation structure

 

In this example, you use the DBM class of the sdb.dbm module to open an connection to the Database Manager and close it again.

Procedure

  1. Create a Python script sample.py with the following contents

    Syntax Syntax

    1. #
      # Import Python modules
      # ----------------------------
      import sys
      import sdb.dbm
      #
      # Parse call arguments
      # --------------------------
      dbm_operator = sys.argv [1]
      dbm_operator_password = sys.argv [2]
      database_name = sys.argv [3]
      #
      # Call up the Database Manager and log on to a database
      # ------------------------------------------------------
      session = sdb.dbm.DBM ('', database_name, '', dbm_operator + ',' + dbm_operator_password)
      #
      # Close the connection to the Database Manager
      # -------------------------------------
      session.release ()
      
    End of the code.
  2. Call the Python script:

    python sample.py DBADMIN SECRET DEMODB