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, MaxDB
HelloMaxDB.py shows
  • how to connect to the database
  • how to execute SQL
  • how to fetch results
  • execute it as
    python HelloMaxDB.py <sqluser> <password> <dbname> <host>
    The command line arguments are optional, the defaults will access the installed example database MAXDB1 with user MONA and password RED.


Accessing SQL using the Python Database API

Hello, MaxDB
HelloMaxDB-API.py shows
  • how to connect to the database
  • how to execute SQL
  • how to fetch results
  • execute it as
    python HelloMaxDB-API.py <sqluser> <password> <dbname> <host>
    The command line arguments are optional, the defaults will access the installed example database MAXDB1 with user MONA and password RED.


Accessing the DB Manager using the sapdb.dbm module

Database state
StateMaxDB.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 StateMaxDB.py <dbmuser> <password> <dbname> <host>
    The command line arguments are optional, the defaults will access the installed example database MAXDB1 with dbm user DBM and password DBM.