When run in Python mode with the py or python argument the HammerDB CLI will accept syntax and commands in Python format with the equivalent script as previous now written as follows:
print("SETTING CONFIGURATION") dbset('db','mssqls') diset('tpcc','mssqls_driver','timed') diset('tpcc','mssqls_rampup',0) diset('tpcc','mssqls_duration',1) vuset('logtotemp',1) loadscript() print("SEQUENCE STARTED") for z in [1,2,4]: print(z," VU TEST") vuset('vu',z) vucreate() vurun() vudestroy() print("TEST SEQUENCE COMPLETE")
and run with output as follows:
C:\Program Files\HammerDB-4.6>hammerdbcli py HammerDB CLI v4.6 Copyright (C) 2003-2022 Steve Shaw Type "help()" for a list of commands hammerdb>>>source('cliexample.py') hammerdb>>>SETTING CONFIGURATION Database set to MSSQLServer Value timed for tpcc:mssqls_driver is the same as existing value timed, no change made Value 0 for tpcc:mssqls_rampup is the same as existing value 0, no change made Value 1 for tpcc:mssqls_duration is the same as existing value 1, no change made Script loaded, Type "print script" to view SEQUENCE STARTED 1 VU TEST Vuser 1 created MONITOR - WAIT IDLE Vuser 2 created - WAIT IDLE Logging activated to C:/Users/Hdb/AppData/Local/Temp/hammerdb.log 2 Virtual Users Created with Monitor VU Vuser 1:RUNNING Vuser 1:Beginning rampup time of 0 minutes Vuser 1:Rampup complete, Taking start Transaction Count. Vuser 1:Timing test period of 1 in minutes Vuser 2:RUNNING Vuser 2:Processing 10000000 transactions with output suppressed... Vuser 1:1 ..., Vuser 1:Test complete, Taking end Transaction Count. Vuser 1:1 Active Virtual Users configured Vuser 1:TEST RESULT : System achieved 46171 NOPM from 107258 SQL Server TPM Vuser 1:FINISHED SUCCESS Vuser 2:FINISHED SUCCESS ALL VIRTUAL USERS COMPLETE vudestroy success 2 VU TEST Vuser 1 created MONITOR - WAIT IDLE Vuser 2 created - WAIT IDLE Vuser 3 created - WAIT IDLE Logging activated to C:/Users/Hdb/AppData/Local/Temp/hammerdb.log 3 Virtual Users Created with Monitor VU Vuser 1:RUNNING Vuser 1:Beginning rampup time of 0 minutes Vuser 1:Rampup complete, Taking start Transaction Count. Vuser 1:Timing test period of 1 in minutes Vuser 2:RUNNING Vuser 2:Processing 10000000 transactions with output suppressed... Vuser 3:RUNNING Vuser 3:Processing 10000000 transactions with output suppressed... Vuser 1:1 ..., Vuser 1:Test complete, Taking end Transaction Count. Vuser 1:2 Active Virtual Users configured Vuser 1:TEST RESULT : System achieved 77825 NOPM from 180859 SQL Server TPM Vuser 1:FINISHED SUCCESS Vuser 3:FINISHED SUCCESS Vuser 2:FINISHED SUCCESS ALL VIRTUAL USERS COMPLETE vudestroy success 4 VU TEST Vuser 1 created MONITOR - WAIT IDLE Vuser 2 created - WAIT IDLE Vuser 3 created - WAIT IDLE Vuser 4 created - WAIT IDLE Vuser 5 created - WAIT IDLE Logging activated to C:/Users/Hdb/AppData/Local/Temp/hammerdb.log 5 Virtual Users Created with Monitor VU Vuser 1:RUNNING Vuser 1:Beginning rampup time of 0 minutes Vuser 1:Rampup complete, Taking start Transaction Count. Vuser 1:Timing test period of 1 in minutes Vuser 2:RUNNING Vuser 2:Processing 10000000 transactions with output suppressed... Vuser 3:RUNNING Vuser 3:Processing 10000000 transactions with output suppressed... Vuser 4:RUNNING Vuser 4:Processing 10000000 transactions with output suppressed... Vuser 5:RUNNING Vuser 5:Processing 10000000 transactions with output suppressed... Vuser 1:1 ..., Vuser 1:Test complete, Taking end Transaction Count. Vuser 1:4 Active Virtual Users configured Vuser 1:TEST RESULT : System achieved 126528 NOPM from 293263 SQL Server TPM Vuser 1:FINISHED SUCCESS Vuser 2:FINISHED SUCCESS Vuser 4:FINISHED SUCCESS Vuser 5:FINISHED SUCCESS Vuser 3:FINISHED SUCCESS ALL VIRTUAL USERS COMPLETE vudestroy success TEST SEQUENCE COMPLETE hammerdb>>>
It is a common requirement to also want to drive HammerDB CLI scripts from an external scripting tool. The HammerDB CLI will accept the argument auto to run a specified script automatically in python mode expecting a python or py argument followed by a filename with a .py extension and Python syntax.
hammerdbcli.bat py auto autorunbuild.py