community / community.general / 3.8.10 / module / hana_query Execute SQL on HANA | "added in version" 3.2.0 of community.general" Authors: Rainer Leber (@rainerleber)community.general.hana_query (3.8.10) — module
Install with ansible-galaxy collection install community.general:==3.8.10
collections: - name: community.general version: 3.8.10
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