community.general.odbc (8.5.0) — module

Execute SQL via ODBC

| "added in version" 1.0.0 of community.general"

Authors: John Westcott IV (@john-westcott-iv)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Read/Write info via ODBC drivers.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Set some values in the test db
  community.general.odbc:
    dsn: "DRIVER={ODBC Driver 13 for SQL Server};Server=db.ansible.com;Database=my_db;UID=admin;PWD=password;"
    query: "Select * from table_a where column1 = ?"
    params:
      - "value1"
    commit: false
  changed_when: false

Inputs

    
dsn:
    description:
    - The connection string passed into ODBC.
    required: true
    type: str

query:
    description:
    - The SQL query to perform.
    required: true
    type: str

commit:
    default: true
    description:
    - Perform a commit after the execution of the SQL query.
    - Some databases allow a commit after a select whereas others raise an exception.
    - Default is V(true) to support legacy module behavior.
    type: bool
    version_added: 1.3.0
    version_added_collection: community.general

params:
    description:
    - Parameters to pass to the SQL query.
    elements: str
    type: list

Outputs

description:
  description: List of dicts about the columns selected from the cursors, likely empty
    for DDL statements. See notes.
  elements: dict
  returned: success
  type: list
results:
  description: List of lists of strings containing selected rows, likely empty for
    DDL statements.
  elements: list
  returned: success
  type: list
row_count:
  description: The number of rows selected or modified according to the cursor defaults
    to -1. See notes.
  returned: success
  type: str