Hacked By AnonymousFox

Current Path : /opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/dialects/sqlite/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/sqlalchemy/dialects/sqlite/__pycache__/pysqlcipher.cpython-311.pyc

�

�܋fT��Z�dZddlmZddlmZddlmZddlmZ	Gd�d	e��Z
e
Zd
S)a�

.. dialect:: sqlite+pysqlcipher
    :name: pysqlcipher
    :dbapi: pysqlcipher
    :connectstring: sqlite+pysqlcipher://:passphrase/file_path[?kdf_iter=<iter>]
    :url: https://pypi.python.org/pypi/pysqlcipher

    ``pysqlcipher`` is a fork of the standard ``pysqlite`` driver to make
    use of the `SQLCipher <https://www.zetetic.net/sqlcipher>`_ backend.

    ``pysqlcipher3`` is a fork of ``pysqlcipher`` for Python 3. This dialect
    will attempt to import it if ``pysqlcipher`` is non-present.

    .. versionadded:: 1.1.4 - added fallback import for pysqlcipher3

    .. versionadded:: 0.9.9 - added pysqlcipher dialect

Driver
------

The driver here is the
`pysqlcipher <https://pypi.python.org/pypi/pysqlcipher>`_
driver, which makes use of the SQLCipher engine.  This system essentially
introduces new PRAGMA commands to SQLite which allows the setting of a
passphrase and other encryption parameters, allowing the database
file to be encrypted.

`pysqlcipher3` is a fork of `pysqlcipher` with support for Python 3,
the driver is the same.

Connect Strings
---------------

The format of the connect string is in every way the same as that
of the :mod:`~sqlalchemy.dialects.sqlite.pysqlite` driver, except that the
"password" field is now accepted, which should contain a passphrase::

    e = create_engine('sqlite+pysqlcipher://:testing@/foo.db')

For an absolute file path, two leading slashes should be used for the
database name::

    e = create_engine('sqlite+pysqlcipher://:testing@//path/to/foo.db')

A selection of additional encryption-related pragmas supported by SQLCipher
as documented at https://www.zetetic.net/sqlcipher/sqlcipher-api/ can be passed
in the query string, and will result in that PRAGMA being called for each
new connection.  Currently, ``cipher``, ``kdf_iter``
``cipher_page_size`` and ``cipher_use_hmac`` are supported::

    e = create_engine('sqlite+pysqlcipher://:testing@/foo.db?cipher=aes-256-cfb&kdf_iter=64000')


Pooling Behavior
----------------

The driver makes a change to the default pool behavior of pysqlite
as described in :ref:`pysqlite_threading_pooling`.   The pysqlcipher driver
has been observed to be significantly slower on connection than the
pysqlite driver, most likely due to the encryption overhead, so the
dialect here defaults to using the :class:`.SingletonThreadPool`
implementation,
instead of the :class:`.NullPool` pool used by pysqlite.  As always, the pool
implementation is entirely configurable using the
:paramref:`_sa.create_engine.poolclass` parameter; the :class:`.StaticPool`
may
be more feasible for single-threaded use, or :class:`.NullPool` may be used
to prevent unencrypted connections from being held open for long periods of
time, at the expense of slower startup time for new connections.


�)�absolute_import�)�SQLiteDialect_pysqlite�)�pool)�urlc�\��eZdZdZdZed���Zed���Z�fd�Z�fd�Z	�xZ
S)�SQLiteDialect_pysqlcipher�pysqlcipher)�kdf_iter�cipher�cipher_page_size�cipher_use_hmacc�t�	ddlm}n/#t$r"}	ddlm}n#t$r|�wxYwYd}~nd}~wwxYw|S)Nr)�dbapi2)rr�ImportError�pysqlcipher3)�cls�	sqlcipher�es   �]/opt/cloudlinux/venv/lib64/python3.11/site-packages/sqlalchemy/dialects/sqlite/pysqlcipher.py�dbapizSQLiteDialect_pysqlcipher.dbapi]s���	�7�7�7�7�7�7�7���	�	�	�
�<�<�<�<�<�<�<���
�
�
���
����=�<�<�<�<�����	����
�s�	�
5��0�
(�0�5c��tjS�N)r�SingletonThreadPool)rrs  r�get_pool_classz(SQLiteDialect_pysqlcipher.get_pool_classhs���'�'�c�V�����dd��}t�fd�|jD����}tt|��j|i���}|�d|z��|���D]#\}}|�|�d|�d|�d����$|S)N�
passphrase�c3�H�K�|]}|��|d��fV��dSr)�pop)�.0�key�cparamss  �r�	<genexpr>z4SQLiteDialect_pysqlcipher.connect.<locals>.<genexpr>os6�����M�M���W�[�[��d�3�3�4�M�M�M�M�M�Mrzpragma key="%s"zpragma z="�")r"�dict�pragmas�superr
�connect�execute�items)	�self�cargsr%rr)�conn�prag�value�	__class__s	  `     �rr+z!SQLiteDialect_pysqlcipher.connectls������[�[��r�2�2�
��M�M�M�M���M�M�M�M�M��=�u�.��5�5�=�
�
��
�
��	
���&��3�4�4�4�"�=�=�?�?�	?�	?�K�D�%�� ��������u�u�u�=�>�>�>���rc����tj|j|j|j|j|j���}tt|���	|��\}}|j
|d<||fS)N)�username�host�database�queryr)�_url�URL�
drivernamer5r6r7r8r*r
�create_connect_args�password)r.r�	super_url�c_args�optsr3s     �rr<z-SQLiteDialect_pysqlcipher.create_connect_args{su����H��N��\����\��)�
�
�
�	��%�t�
�
�
�
�i�
(�
(�	���!�\��\���t�|�r)�__name__�
__module__�__qualname__�driverr)�classmethodrrr+r<�
__classcell__)r3s@rr
r
Xs��������
�F�K�G�����[���(�(��[�(�
�
�
�
�
���������rr
N)�__doc__�
__future__r�pysqliterr r�enginerr9r
�dialect�rr�<module>rMs���G�G�R'�&�&�&�&�&�,�,�,�,�,�,�������!�!�!�!�!�!�/�/�/�/�/� 6�/�/�/�d$���r

Hacked By AnonymousFox1.0, Coded By AnonymousFox