Procedure documentationExample: Logging onto a Database Locate this document in the navigation structure

 

In this example, you use the Loader class of the sdb.loader module to start the Loader and log on to a database.

Procedure

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

    Syntax Syntax

    1. # Import Python modules
      # -------------------------------------------
      import sys
      import sdb.loader
      # Call Loader
      # -------------------------------------------
      session = sdb.loader.Loader ()
      #Logging On to the Database
      # -------------------------------------------
      session.cmd ("USE USER MONA RED DB DEMODB")
      # Close connection to the database
      # -------------------------------------------
      session.release ()
      
    End of the code.
  2. Call the Python script:

    python sample.py