File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar/__pycache__/sqlite3.cpython-310.pyc
o
�N�g�
� @ sZ d Z ddlZddlZddlmZ ddlmZ e�e�Z dd� Z
G dd� de�Zd d
� ZdS )a�
Retrieve Pillar data by doing a SQLite3 query
.. versionadded:: 2015.8.0
``sqlite3`` is included in the stdlib since Python 2.5.
This module is a concrete implementation of the sql_base ext_pillar for
SQLite3.
:platform: all
Configuring the sqlite3 ext_pillar
==================================
Use the 'sqlite3' key under ext_pillar for configuration of queries.
SQLite3 database connection configuration requires the following values
configured in the master config:
Note, timeout is in seconds.
.. code-block:: yaml
sqlite3.database: /var/lib/salt/pillar.db
sqlite3.timeout: 5.0
Complete Example
================
.. code-block:: yaml
sqlite3:
database: '/var/lib/salt/pillar.db'
timeout: 5.0
ext_pillar:
- sqlite3:
fromdb:
query: 'SELECT col1,col2,col3,col4,col5,col6,col7
FROM some_random_table
WHERE minion_pattern LIKE ?'
depth: 5
as_list: True
with_lists: [1,3]
� N)�contextmanager)�SqlBaseExtPillarc C � dS )NT� r r r �G/opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar/sqlite3.py�__virtual__; s r c @ s0 e Zd ZdZedd� �Zdd� Zedd� �ZdS ) �SQLite3ExtPillarzK
This class receives and processes the database rows from SQLite3.
c C r )NZSQLite3r )�clsr r r �_db_nameD s zSQLite3ExtPillar._db_namec C sn ddd�}i }i }dt v rdt d v rt �di �}|D ]}||vr.t�d|� || ||<