File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar/__pycache__/mysql.cpython-310.pyc
Back
o ;j � @ s� d Z ddlZddlmZ ddlmZ e�e�Zzddl Z ddl Z ddlZ W n+ eyP zddl Z e �� ddl Z ddl Z ddlZ W n eyM dZ Y nw Y nw dd� ZG dd� de�Zd d � ZdS )a� Retrieve Pillar data by doing a MySQL query MariaDB provides Python support through the MySQL Python package. Therefore, you may use this module with both MySQL or MariaDB. This module is a concrete implementation of the sql_base ext_pillar for MySQL. :maturity: new :depends: python-mysqldb :platform: all Configuring the mysql ext_pillar ================================ Use the 'mysql' key under ext_pillar for configuration of queries. MySQL configuration of the MySQL returner is being used (mysql.db, mysql.user, mysql.pass, mysql.port, mysql.host) for database connection info. Required python modules: MySQLdb Complete example ================ .. code-block:: yaml mysql: user: 'salt' pass: 'super_secret_password' db: 'salt_db' port: 3306 ssl: cert: /etc/mysql/client-cert.pem key: /etc/mysql/client-key.pem ext_pillar: - mysql: fromdb: query: 'SELECT col1,col2,col3,col4,col5,col6,col7 FROM some_random_table WHERE minion_pattern LIKE %s' depth: 5 as_list: True with_lists: [1,3] � N)�contextmanager)�SqlBaseExtPillarc C s t t�tdu r dfS dfS )z: Confirm that a python mysql client is installed. Nz!No python mysql client installed.� )�bool�MySQLdb� r r �E/opt/saltstack/salt/lib/python3.10/site-packages/salt/pillar/mysql.py�__virtual__J s r c s@ e Zd ZdZedd� �Zdd� Zedd� �Z� fdd �Z � Z S ) �MySQLExtPillarzI This class receives and processes the database rows from MySQL. c C s dS )NZMySQLr )�clsr r r �_db_nameV s zMySQLExtPillar._db_namec C s^ dddddi d�}i }t �di �}|D ]}||vr&t�d|� || ||<