ttafsir / ttafsir.sqlite_utils / 1.4.0 / lookup / sqlite Query SQLite databases using the sqlite-utils package Authors: Tafsir Thiam (@ttafsir)ttafsir.sqlite_utils.sqlite (1.4.0) — lookup
Install with ansible-galaxy collection install ttafsir.sqlite_utils:==1.4.0
collections: - name: ttafsir.sqlite_utils version: 1.4.0
The sqlite lookup plugin allows querying SQLite databases using the sqlite-utils package.
Features include filtering rows, selecting specific columns, ordering results, and counting rows.
- name: Fetch all rows from SQLite debug: msg: "{{ lookup('ttafsir.sqlite_utils.sqlite', table='emails', db_path='database.db') }}"
- name: Fetch single column from SQLite debug: msg: "{{ lookup('ttafsir.sqlite_utils.sqlite', table='emails', db_path='database.db', select='email_id') }}"
- name: Fetch two columns from SQLite debug: msg: "{{ lookup('ttafsir.sqlite_utils.sqlite', table='emails', db_path='database.db', select='email_id, subject') }}"
- name: Fetch single row using a WHERE clause debug: msg: "{{ lookup('ttafsir.sqlite_utils.sqlite', table='emails', db_path='database.db', where='subject = :subject', where_args={'subject': 'Peek #4'}) }}"
- name: Loop through all rows and display a specific column debug: msg: "{{ item.subject }}" loop: "{{ lookup('ttafsir.sqlite_utils.sqlite', table='emails', db_path='database.db') }}"
count: description: Return count of rows instead of rows themselves. type: bool limit: description: Limit the number of returned results. type: int where: description: Optional WHERE clause. type: str offset: description: Offset for returned results. type: int select: description: Columns to select. Default is '*'. type: str db_path: description: - Path to the SQLite database. - Defaults to the SQLITE_DB_PATH environment variable. type: str order_by: description: Order results by specified column(s). type: str table_name: description: Name of the table to query. required: true type: str where_args: description: Optional arguments for the WHERE clause. type: raw