U
�AT^ c @ s d d� Z dS )c
c s | � � }dV d}|�|�}|�� D ]�\}}}|dkr>dV n*|dkrNdV n|�d�r\q$nd�|�V |�d d
�}|�d�|��}dd
� |�� D �} d�|d�dd� | D ���}|�|�}
|
D ]}d�|d �V q�q$d}|�|�}|�� D ]\}}}d�|�V q�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"
Zsqlite_sequencezDELETE FROM "sqlite_sequence";Zsqlite_stat1zANALYZE "sqlite_master";Zsqlite_z{0};�"�""zPRAGMA table_info("{0}")c S s g | ]}t |d ��qS )i )Zstr)�.0Z
table_info� r �$/usr/lib64/python3.8/sqlite3/dump.pyZ
<listcomp>3 s z_iterdump.<locals>.<listcomp>z2SELECT 'INSERT INTO "{0}" VALUES({1})' FROM "{0}";z,c s s | ]}d � |�dd��V qdS )z'||quote("{0}")||'r r N)�format�replace)r Zcolr r r Z <genexpr>6 s z_iterdump.<locals>.<genexpr>i z�
SELECT "name", "type", "sql"
FROM "sqlite_master"
WHERE "sql" NOT NULL AND
"type" IN ('index', 'trigger', 'view')
zCOMMIT;N)ZcursorZexecuteZfetchallZ
startswithr r Zjoin)
Z
connectionZcuZqZ
schema_resZ
table_nameZtypeZsqlZtable_name_identZresZcolumn_namesZ query_resZrowZnamer r r � _iterdump
s6
�
r N)r r r r r Z<module>
s