U
    kÖ]e	  ã                   @   s   d d„ Z dS )c                 c   s  |   ¡ }dV  d}| |¡}| ¡ D ]²\}}}|dkr>dV  n*|dkrNdV  n| d¡r\q$nd |¡V  | d	d
¡}| d |¡¡}dd„ | ¡ D ƒ}	d |d dd„ |	D ƒ¡¡}| |¡}
|
D ]}d |d ¡V  qÀq$d}| |¡}| ¡ D ]\}}}d |¡V  qîdV  dS )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().
    zBEGIN TRANSACTION;zª
        SELECT "name", "type", "sql"
        FROM "sqlite_master"
            WHERE "sql" NOT NULL AND
            "type" == 'table'
            ORDER BY "name"
        Zsqlite_sequencezDELETE FROM "sqlite_sequence";Zsqlite_stat1zANALYZE "sqlite_master";Zsqlite_z{0};ú"ú""zPRAGMA table_info("{0}")c                 S   s   g | ]}t |d  ƒ‘qS )é   )Ústr)Ú.0Z
table_info© r   ú"/usr/lib/python3.8/sqlite3/dump.pyÚ
<listcomp>3   s     z_iterdump.<locals>.<listcomp>z2SELECT 'INSERT INTO "{0}" VALUES({1})' FROM "{0}";ú,c                 s   s    | ]}d   | dd¡¡V  qdS )z'||quote("{0}")||'r   r   N)ÚformatÚreplace)r   Úcolr   r   r   Ú	<genexpr>6   s     z_iterdump.<locals>.<genexpr>é    z£
        SELECT "name", "type", "sql"
        FROM "sqlite_master"
            WHERE "sql" NOT NULL AND
            "type" IN ('index', 'trigger', 'view')
        zCOMMIT;N)ZcursorZexecuteZfetchallÚ
startswithr
   r   Újoin)Z
connectionZcuÚqZ
schema_resZ
table_nameÚtypeZsqlZtable_name_identÚresZcolumn_namesZ	query_resÚrowÚnamer   r   r   Ú	_iterdump
   s6    	

	þ

r   N)r   r   r   r   r   Ú<module>
   ó    