%PDF- %PDF-
| Direktori : /proc/self/root/proc/self/root/usr/lib/python2.7/site-packages/salt/pillar/ |
| Current File : //proc/self/root/proc/self/root/usr/lib/python2.7/site-packages/salt/pillar/sqlite3.pyo |
�
���^c @@ s� d Z d d l m Z m Z m Z d d l m Z d d l Z d d l Z d d l m
Z
e j e � Z
d � Z d e
f d � � YZ d � Z d S(
u�
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]
i ( t absolute_importt print_functiont unicode_literals( t contextmanagerN( t SqlBaseExtPillarc C@ s t S( N( t True( ( ( s7 /usr/lib/python2.7/site-packages/salt/pillar/sqlite3.pyt __virtual__? s t SQLite3ExtPillarc B@ s5 e Z d Z e d � � Z d � Z e d � � Z RS( uK
This class receives and processes the database rows from SQLite3.
c C@ s d S( Nu SQLite3( ( t cls( ( s7 /usr/lib/python2.7/site-packages/salt/pillar/sqlite3.pyt _db_nameG s c C@ s� i d d 6d d 6} i } i } d t k rQ d t d k rQ t j d i � } n xL | D]D } | | k r� t j d | � | | | | <qX n | | | | <qX W| S( uB
Returns options used for the SQLite3 connection.
u /var/lib/salt/pillar.dbu databaseg @u timeoutu sqlite3u# Using default for SQLite3 pillar %s( t __opts__t gett logt debug( t selft defaultst _optionst _optst attr( ( s7 /usr/lib/python2.7/site-packages/salt/pillar/sqlite3.pyt _get_optionsK s
c c@ s� | j � } t j | j d � d t | j d � � �} | j � } z9 y | VWn) t j k
r| } t j d | j � n XWd | j
� Xd S( u(
Yield a SQLite3 cursor
u databaset timeoutu timeoutu Error in ext_pillar SQLite3: %sN( R t sqlite3t connectR t floatt cursort ErrorR t exceptiont argst close( R R t connR t err( ( s7 /usr/lib/python2.7/site-packages/salt/pillar/sqlite3.pyt _get_cursor] s ( t __name__t
__module__t __doc__t classmethodR R R R ( ( ( s7 /usr/lib/python2.7/site-packages/salt/pillar/sqlite3.pyR C s c O@ s t � j | | | | � S( uE
Execute queries against SQLite3, merge and return as a dict
( R t fetch( t minion_idt pillarR t kwargs( ( s7 /usr/lib/python2.7/site-packages/salt/pillar/sqlite3.pyt
ext_pillarn s ( R"