%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/sdb/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/sdb/sqlite3.pyo

�
���^c@@s�dZddlmZmZmZddlZddlZyddlZeZ	Wne
k
rieZ	nXddlm
Z
ddlZdZeje�Zidd6Zd�Zd	d
�Zd�Zdd�Zdd
�ZdS(u�
SQLite sdb Module

:maintainer:    SaltStack
:maturity:      New
:platform:      all

This module allows access to sqlite3 using an ``sdb://`` URI

Like all sdb modules, the sqlite3 module requires a configuration profile to
be configured in either the minion or master configuration file. This profile
requires very little. For example:

.. code-block:: yaml

    mysqlite:
      driver: sqlite3
      database: /tmp/sdb.sqlite
      table: sdb
      create_table: True

The ``driver`` refers to the sqlite3 module, ``database`` refers to the sqlite3
database file. ``table`` is the table within the db that will hold keys and
values (defaults to ``sdb``). The database and table will be created if they
do not exist.

Advanced Usage:
===============

Instead of a table name, it is possible to provide custom SQL statements to
create the table(s) and get and set values.

.. code-block: yaml

    myadvanced
      driver: sqlite3
      database: /tmp/sdb-advanced.sqlite
    create_statements:
      - "CREATE TABLE advanced (a text, b text, c blob, d blob)"
      - "CREATE INDEX myidx ON advanced (a)"
    get_query: "SELECT d FROM advanced WHERE a=:key"
    set_query: "INSERT OR REPLACE INTO advanced (a, d) VALUES (:key, :value)"
i(tabsolute_importtprint_functiontunicode_literalsN(tsixusdbusetuset_cC@sts
tStS(u,
    Only load if sqlite3 is available.
    (tHAS_SQLITE3tFalsetTrue(((s4/usr/lib/python2.7/site-packages/salt/sdb/sqlite3.pyt__virtual__HsustrictcC@s�|jd|�jd�}|jd�}|dkr�td|||dd�}tj|�}||�\}}|jd|�}nd|jdd�dS(	Nuutf-8uiuNUL-terminated utf-8iuNUL not allowedu"u""(tencodetdecodetfindtUnicodeEncodeErrortcodecstlookup_errortreplace(tsterrorst	encodablet	nul_indexterrort
error_handlertreplacementt_((s4/usr/lib/python2.7/site-packages/salt/sdb/sqlite3.pyt_quoteQs	cC@s�|d}d}tj|�}|j�}|jd�}|jdt�}t|d�}t|�}yo|r�xb|D]}|j|�qxWnD|jdt�r�|jdj	|��|jdj	||��nWntj
k
r�nX|||fS(Nudatabaseucreate_statementsutableu_idxucreate_tableu'CREATE TABLE {0} (key text, value blob)u$CREATE UNIQUE INDEX {0} ON {1} (key)(tNonetsqlite3tconnecttcursortgett
DEFAULT_TABLERtexecuteRtformattOperationalError(tprofiletdbttabletconntcurtstmtstidxtsql((s4/usr/lib/python2.7/site-packages/salt/sdb/sqlite3.pyt_connect`s(


cC@s�|s
tSt|�\}}}tjr@ttj|��}nttj|��}|jddj	|��}|j
|i|d6|d6�|j�tS(u)
    Set a key/value pair in sqlite3
    u	set_queryu0INSERT OR REPLACE INTO {0} VALUES (:key, :value)ukeyuvalue(
RR)RtPY2tbuffertmsgpacktpackbt
memoryviewRRRtcommitR(tkeytvalueR!R$R%R#tq((s4/usr/lib/python2.7/site-packages/salt/sdb/sqlite3.pytset_ys	
cC@sz|s
dSt|�\}}}|jddj|��}|j|i|d6�}|j�}|sidStj|d�S(u"
    Get a value from sqlite3
    u	get_queryu$SELECT value FROM {0} WHERE key=:keyukeyiN(RR)RRRtfetchoneR,tunpackb(R0R!RR%R#R2tres((s4/usr/lib/python2.7/site-packages/salt/sdb/sqlite3.pyR�s(t__doc__t
__future__RRRtloggingRRRRtImportErrorRtsalt.extRR,Rt	getLoggert__name__tlogt__func_alias__RRR)RR3R(((s4/usr/lib/python2.7/site-packages/salt/sdb/sqlite3.pyt<module>,s&



			

Zerion Mini Shell 1.0