î
\á[\	  ã               @   s   d  d „  Z  d S)c             c   sz  |  j  ƒ  } d Vd } | j | ƒ } x| j ƒ  D]÷ \ } } } | d k rV d Vn7 | d k rj d Vn# | j d ƒ r q3 n d j | ƒ V| j d	 d
 ƒ } | j d j | ƒ ƒ } d d „  | j ƒ  Dƒ }	 d j | d j d d „  |	 Dƒ ƒ ƒ } | j | ƒ }
 x  |
 D] } d j | d ƒ VqWq3 Wd } | j | ƒ } x+ | j ƒ  D] \ } } } d j | ƒ VqPWd 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""zPRAGMA table_info("{0}")c             S   s    g  |  ] } t  | d  ƒ ‘ q S)é   )Ústr)Ú.0Z
table_info© r   ú"/usr/lib/python3.4/sqlite3/dump.pyú
<listcomp>3   s   	 z_iterdump.<locals>.<listcomp>z2SELECT 'INSERT INTO "{0}" VALUES({1})' FROM "{0}";ú,c             s   s*   |  ]  } d  j  | j d d ƒ ƒ Vq d S)z'||quote("{0}")||'r   z""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_identZresZcolumn_namesZ	query_resÚrowÚnamer   r   r   Ú	_iterdump
   s4    			r   N)r   r   r   r   r   Ú<module>
   s    