HowTo: Python


Prerequisites


All the files required to run the examples are contained in the directory $DEP/doc/FirstSteps/Python.


Accessing SQL using the sapdb.sql module

Hello, SAP DB
HelloSAPDB.py shows
  • how to connect to the database
  • how to execute SQL
  • how to fetch results
  • execute it as
    python HelloSAPDB.py <sqluser> <password> <dbname> <host>
    The command line arguments are optional, the defaults will access the installed demo database


Accessing SQL using the Python Database API

Hello, SAP DB
HelloSAPDB-API.py shows
  • how to connect to the database
  • how to execute SQL
  • how to fetch results
  • execute it as
    python HelloSAPDB-API.py <sqluser> <password> <dbname> <host>
    The command line arguments are optional, the defaults will access the installed demo database


Accessing the DB Manager using the sapdb.dbm module

Database state
StateSAPDB.py shows
  • how to connect to the Database Manager
  • how to execute simple commands using the dbmcli syntax
  • how to parse results
  • execute it as
    python StateSAPDB.py <dbmuser> <password> <dbname> <host>
    The command line arguments are optional, the defaults will access the installed demo database