o
    ^h                     @   s   d d Z dS )c                 c   sJ   |   }dV  d}||}g }| D ]h\}}}|dkr2|d }dg}|dd |D 7 }q|dkr:d	V  n|d
r@qd|V  |dd}	|d|	}
dd |
 D }d|	ddd |D }||}|D ]
}d|d V  qrqd}||}| D ]\}}}d|V  q|D ]}d|V  qd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"
        sqlite_sequencez SELECT * FROM "sqlite_sequence";zDELETE FROM "sqlite_sequence"c                 S   s&   g | ]}d |d  d|d  dqS )z&INSERT INTO "sqlite_sequence" VALUES('    z',   ) ).0rowr   r     /home/conda/feedstock_root/build_artifacts/python-split_1761171407825/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehol/lib/python3.10/sqlite3/dump.py
<listcomp>$   s    z_iterdump.<locals>.<listcomp>Zsqlite_stat1zANALYZE "sqlite_master";Zsqlite_z{0};"""zPRAGMA table_info("{0}")c                 S   s   g | ]}t |d  qS )r   )str)r   Z
table_infor   r   r   r	   :   s    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>=   s     z_iterdump.<locals>.<genexpr>r   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)
connectionZcuqZ
schema_resr   Z
table_nametypeZsqlZrowsZtable_name_identresZcolumn_namesZ	query_resr   namer   r   r   	_iterdump
   sJ   	

	


r   N)r   r   r   r   r   <module>   s   	