community / community.general / 6.6.8 / module / hana_query Execute SQL on HANA | "added in version" 3.2.0 of community.general" Authors: Rainer Leber (@rainerleber)community.general.hana_query (6.6.8) — module
Install with ansible-galaxy collection install community.general:==6.6.8
collections: - name: community.general version: 6.6.8
This module executes SQL statements on HANA with hdbsql.
- name: Simple select query community.general.hana_query: sid: "hdb" instance: "01" password: "Test123" query: "select user_name from users"
- name: Run several queries community.general.hana_query: sid: "hdb" instance: "01" password: "Test123" query: - "select user_name from users;" - select * from SYSTEM; host: "localhost" autocommit: false
- name: Run several queries from file community.general.hana_query: sid: "hdb" instance: "01" password: "Test123" filepath: - /tmp/HANA_CPU_UtilizationPerCore_2.00.020+.txt - /tmp/HANA.txt host: "localhost"
- name: Run several queries from user store community.general.hana_query: sid: "hdb" instance: "01" user: hdbstoreuser userstore: true query: - "select user_name from users;" - select * from users; autocommit: false
sid: description: The system ID. required: true type: str host: description: The Host IP address. The port can be defined as well. type: str user: default: SYSTEM description: A dedicated username. The user could be also in hdbuserstore. Defaults to C(SYSTEM). type: str query: description: - SQL query to run. - Must be a string or list containing strings. Please note that if you supply a string, it will be split by commas (C(,)) to a list. It is better to supply a one-element list instead to avoid mangled input. elements: str type: list database: description: Define the database on which to connect. type: str filepath: description: - One or more files each containing one SQL query to run. - Must be a string or list containing strings. elements: path type: list instance: description: The instance number. required: true type: str password: description: - The password to connect to the database. - B(Note:) Since the passwords have to be passed as command line arguments, I(userstore=true) should be used whenever possible, as command line arguments can be seen by other users on the same machine. type: str encrypted: default: false description: Use encrypted connection. Defaults to C(false). type: bool userstore: default: false description: If C(true) the user must be in hdbuserstore. type: bool version_added: 3.5.0 version_added_collection: community.general autocommit: default: true description: Autocommit the statement. type: bool
query_result: description: List containing results of all queries executed (one sublist for every query). elements: list returned: on success sample: - - Column: Value1 - Column: Value2 - - Column: Value1 - Column: Value2 type: list