�
*�Kg� � � � d � Z dS )c # �� K � | � � � }dV � d}|� |� � }g }|� � � D �]E\ }}}|dk r:|� d� � � � � }dg}|d� |D � � z
}�G|dk rdV � n-|� d � � r�hd
� |� � V � |� dd� � } |� d
� | � � � � }
d� |
� � � D � � }d� | d� d� |D � � � � � � }|� |� � }|D ]}
d
� |
d � � V � � ��Gd}|� |� � }|� � � D ]\ }}}d
� |� � V � �|D ]}
d
� |
� � V � �dV � dS )a/
Returns an iterator to the dump of the database in an SQL text format.
Used to produce an SQL dump of the database. Useful to save an in-memory
database for later restoration. This function should not be called
directly but instead called from the Connection method, iterdump().
zBEGIN TRANSACTION;z�
SELECT "name", "type", "sql"
FROM "sqlite_master"
WHERE "sql" NOT NULL AND
"type" == 'table'
ORDER BY "name"
�sqlite_sequencez SELECT * FROM "sqlite_sequence";zDELETE FROM "sqlite_sequence"c �8 � g | ]}d |d � d|d � d���S )z&INSERT INTO "sqlite_sequence" VALUES('� z',� �)� )�.0�rows �#/usr/lib/python3.11/sqlite3/dump.py�
<listcomp>z_iterdump.<locals>.<listcomp>$ sD � � � � �� O�#�a�&�N�N�S��V�N�N�N� � � � �sqlite_stat1zANALYZE "sqlite_master";�sqlite_z{0};�"�""zPRAGMA table_info("{0}")c �8 � g | ]}t |d � � ��S )r )�str)r �
table_infos r r z_iterdump.<locals>.<listcomp>: s$ � �L�L�L�z��J�q�M�*�*�L�L�Lr
z2SELECT 'INSERT INTO "{0}" VALUES({1})' FROM "{0}";�,c 3 �h K � | ]-}d � |� dd� � � � V � �.dS )z'||quote("{0}")||'r r N)�format�replace)r �cols r � <genexpr>z_iterdump.<locals>.<genexpr>= s@ � � � �e�e�QT�-�4�4�S�[�[��d�5K�5K�L�L�e�e�e�e�e�er
r z�
SELECT "name", "type", "sql"
FROM "sqlite_master"
WHERE "sql" NOT NULL AND
"type" IN ('index', 'trigger', 'view')
zCOMMIT;N)�cursor�execute�fetchall�
startswithr r �join)�
connection�cu�q�
schema_resr �
table_name�type�sql�rows�table_name_ident�res�column_names� query_resr
�names r � _iterdumpr-
sq � � � �
� � � � �B�
���� �A� ���A���J��O�!+�!4�!4�!6�!6� )� )��
�D�#��*�*�*��:�:�@�A�A�J�J�L�L�D�>�?�O�� � �� � � �
�O�
�
�>�
)�
)�,�-�-�-�-�
�
"�
"�9�
-�
-�
&�� �-�-��$�$�%�%�%� &�-�-�c�4�8�8���j�j�3�:�:�;K�L�L�M�M��L�L�S�\�\�^�^�L�L�L��D�K�K���H�H�e�e�Xd�e�e�e�e�e�
g�
g�� �J�J�q�M�M� �� )� )�C��-�-��A��'�'�(�(�(�(� )� �A� ���A���J�%�.�.�0�0� "� "���d�C��m�m�C� � �!�!�!�!� � "� "���m�m�C� � �!�!�!�!�
�����r
N)r- r r
r �<module>r. s# ��H� H� H� H� Hr
|