Skip to Content
Author's profile photo Former Member

10 Useful Python script for HANA

Python support scripts of the HANA Database as HANA 1.0 SPS12

The python support can be found in /usr/sap/<SID>/HDB<XX>/exe/python_support.
Usually you can use the option ‘–help’ and ‘–helpGeneral’ on each scripts. Be carefeful before you execute one, these scripts can impact the system.
You can use combined with the script, which passes the necessary variables towards.
Example: –help
Collects diagnosis information from the SAP HANA database
Some options:
Collects trace files starting from the specified date
(format: YYYY-MM-DD)
Collects trace files up to the specified date (format:
Path to exported tables/views
-t TENANT, –tenant=TENANT
Specifies the tenant where the files are to be
python -F 20171110 -T 20171112 (download from 2399996)
Reads values from various HDB ini files.
python –key=global/persistence/log_mode
Cleans up backup catalog, trace files, alerts, audit logs, etc – can be set as a periodic task.
This script is an expert tool designed by SAP support. You are allowed to use it, but SAP doesn’t take over any responsibility for problems originating from the use of this tool.
(trace files, statistics server alerts and backup catalog entries, i.e. not the backups themselves, older than 42 days
are deleted and backup logs bigger than 50 mb are compressed and renamed and logsegments a removed if more than 20
free once exist for a service):
> python -tc 42 -tf 42 -ar 42 -bd 42 -zb 50 -lr 20 -eh 2 eu -42
AUTHOR: Christian Hansen
(2399996 – How-To: Configuring automatic SAP HANA Cleanup with SAP HANACleaner)
Show complete HW information
python -v
Shows the hosts’ groups, roles and status of the landscape.
Initiates a delta merge on a column table
python [options] tableName
See also:
Analyzes the memory consumption of the system. [options]
Check note for details: 1698281 – Assess the memory consumption of a SAP HANA System
Measurement Options:
if yes (no), (do not) load tables before sizing
[default: yes]
immediately unload a table after loading (possible
values: no, unloaded, partially_loaded, all) – only
relevant together with –loadTables yes [default: no]
if yes (no), (do not) merge and compress tables before
sizing [default: yes]
Example: -a localhost:30015 -u SYSTEM -p ******* -l LOADTABLES
Recovers the database or cancel the recovery process.
Emergency restore & recover is possible even if database is not able to start. [<parameters>]
Examples: –command=”RECOVER DATABASE UNTIL TIMESTAMP ‘2017-11-10 07:00:00′” –command=”RECOVER DATABASE UNTIL TIMESTAMP ‘2017-11-10 07:00:00’ USING LOG PATH (‘/remote/backup/P50/log’) USING BACKUP_ID 1380740405546 CHECK ACCESS USING FILE”
Shows base system information, such as Instance, Services, Disk, Memory details.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Jens Gleichmann
      Jens Gleichmann

      Hi Kyle,

      thanks for sharing the details and examples.

      All Python scripts delivered with HANA can be found with the alias cdpy (as sidadm) or unter the path /usr/sap/<SID>/HDB<instancenumber>/exe/python_support.

      To add some further useful python scripts:

      • => to load all tables of a schema into memory (usage: python --help)
      • => status of HSR
      • => OS level, HANA version, disk status etc.
      • => index advisor for column tables (usage: python -h)

      Python scripts are depend on HANA SPS and revision level.



      Author's profile photo Subith Balakrishnan
      Subith Balakrishnan

      Thanks Kyle and Jens for a list of verfy useful set of scripts. For those who want to run them in a shell script for some reason, here's the syntax that worked for me :

      /usr/sap/{SID}/SYS/global/hdb/install/support/ /usr/sap/{SID}/HDB{INST_NUM}/exe/python_support/ --args


      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks for the additions and highlights, this is exactly how I imagined this article at first place, with excellent comments together 🙂