Skip Top Menu Navigation
Skip Top Menu Navigation

The FREE Enterprise Open Source Database

  Software Tools Interfaces Development Documentation
 

 
You Are Here:    SAP DB > 7.3 > Interfaces > repman > Example

SAP DB is now SAP MaxDB! For more information, visit the SAP MaxDB pages in the SAP Developer Network.

Module repman (Example)

#
# egRPM.py   call as
#        python egRPM.py <user> <pwd> <db> [<host>]
#

import sys
import repman

user = sys.argv [1]
pwd = sys.argv [2]
dbname = sys.argv [3]
try:
    host = sys.argv [4]
except IndexError:
    host = 'localhost'

# connect to db
session = repman.RepMan (host, dbname)

# execute simple command
print 'Version:', session.cmd ('version;')

# connect
session.cmd ('use user %s %s;' % (user, pwd))
print 'connected'

# create a table and drop it
for cmd in ['create table loadtest (a char (10))',
        'drop table loadtest']:
    print cmd,
    session.cmd (cmd + ';')
    print '-> ok'

# demonstrate exception handling
try:
    result = session.cmd ('complete nonsense;')
    print "'%s'" % result
except repman.RepManServError, err:
    print 'command failed:', err

# demonstrate sql method
cmd = 'complete nonsense;'
rc = session.sql (cmd)
print cmd, '->', rc;

session = None



Search
See also ...












Questions or comments about the Web site? Contact the webmaster.