Ë
    òT•j  ã                   ó–   — d Z ddlZddlZddlmZ ddlmZ ddlmZ dd„Z	 G d„ de«      Z
d	„ Zed
k(  r eej                  dd «       yy)zÞA simple SQLite CLI for the sqlite3 module.

Apart from using 'argparse' for the command-line interface,
this module implements the REPL as a thin wrapper around
the InteractiveConsole class from the 'code' stdlib module.
é    N)ÚArgumentParser)ÚInteractiveConsole)Údedentc                 ó¦  — 	 | j                  |«      D ]  }t        |«       Œ y# t        j                  $ r™}t	        |«      j
                  }	 t        |› d|j                  › d|› �t        j                  ¬«       n/# t        $ r# t        |› d|› �t        j                  ¬«       Y nw xY w|st        j                  d«       Y d}~yY d}~yd}~ww xY w)zÈHelper that wraps execution of SQL code.

    This is used both by the REPL and by direct execution from the CLI.

    'c' may be a cursor or a connection.
    'sql' is the SQL string to execute.
    z (z): )Úfilez: é   N)ÚexecuteÚprintÚsqlite3ÚErrorÚtypeÚ__name__Úsqlite_errornameÚsysÚstderrÚAttributeErrorÚexit)ÚcÚsqlÚsuppress_errorsÚrowÚeÚtps         ú'/usr/lib/python3.12/sqlite3/__main__.pyr	   r	      s¯   € ð
Ø—9‘9˜S“>ò 	ˆCÜ�#�Jñ	øä�=‰=ò Ü�!‹W×Ñˆð	1Ü�R�D˜˜1×-Ñ-Ð.¨c°!°Ð5¼C¿J¹JÖGøÜò 	1Ü�R�D˜˜1˜#�,¤S§Z¡Z×0ð	1úáÜ�H‰H�Q�K‰Kô ûðús8   ‚!$ ¤C·CÁ-A;Á:CÁ;)B'Â$CÂ&B'Â'CÃCc                   ó*   ‡ — e Zd ZdZˆ fd„Zdd„Zˆ xZS )ÚSqliteInteractiveConsolezA simple SQLite REPL.c                 óZ   •— t         ‰| �  «        || _        |j                  «       | _        y )N)ÚsuperÚ__init__Ú_conÚcursorÚ_cur)ÚselfÚ
connectionÚ	__class__s     €r   r   z!SqliteInteractiveConsole.__init__(   s%   ø€ Ü‰ÑÔØˆŒ	Ø×%Ñ%Ó'ˆ�	ó    c                 óú   — |xdk(  r t        t        j                  › «       yxdk(  r t        d«       ydk(  rt        j                  d«       y	 t        j
                  |«      syt        | j                  |«       y)zßOverride runsource, the core of the InteractiveConsole REPL.

        Return True if more input is needed; buffering is done automatically.
        Return False is input is a complete statement ready for execution.
        z.versionz.helpzEnter SQL code and press enter.z.quitr   TF)r
   r   Úsqlite_versionr   r   Úcomplete_statementr	   r"   )r#   ÚsourceÚfilenameÚsymbols       r   Ú	runsourcez"SqliteInteractiveConsole.runsource-   so   € ð ÝÜœ×/Ñ/Ð0Ô2ð õ ÜÐ7Ô8ð ó Ü—‘˜”ð
 ð	 Ü×1Ñ1°&Ô9ØÜ˜Ÿ	™	 6Ô*Ør&   )z<input>Úsingle)r   Ú
__module__Ú__qualname__Ú__doc__r   r-   Ú__classcell__)r%   s   @r   r   r   %   s   ø„ Ùô(÷
r&   r   c            	      ó^  — t        dd¬«      }|j                  dt        ddd¬«       |j                  d	t        dd
¬«       |j                  ddddt        j                  › �d¬«        |j
                  | Ž } | j                  dk(  rd}nt        | j                  «      }t        j                  dk(  rdt        j                  vrd}nd}t        dt        j                  › d|› d|› d�«      j                  «       }dt        _        dt        _        t        j                  | j                  d ¬«      }	 | j                   rt#        || j                   d¬«       nt%        |«      }|j'                  |d ¬!«       |j)                  «        t        j*                  d"«       y # |j)                  «        w xY w)#NzPython sqlite3 CLIzpython -m sqlite3)ÚdescriptionÚprogr+   z:memory:ú?zrSQLite database to open (defaults to ':memory:'). A new database is created if the file does not previously exist.)r   ÚdefaultÚnargsÚhelpr   zAAn SQL query to execute. Any returned rows are printed to stdout.)r   r8   r9   z-vz	--versionÚversionzSQLite version z'Print underlying SQLite library version)Úactionr:   r9   za transient in-memory databaseÚwin32zidlelib.runzCTRL-ZzCTRL-Dz2
        sqlite3 shell, running on SQLite version z
        Connected to z}

        Each command will be run using execute() on the cursor.
        Type ".help" for more information; type ".quit" or z to quit.
    zsqlite> z    ... )Úisolation_levelF)r   Ú )Úexitmsgr   )r   Úadd_argumentÚstrr   r(   Ú
parse_argsr+   Úreprr   ÚplatformÚmodulesr   ÚstripÚps1Úps2Úconnectr   r	   r   ÚinteractÚcloser   )ÚargsÚparserÚdb_nameÚeofkeyÚbannerÚconÚconsoles          r   ÚmainrS   A   s§  € ÜØ(Ø ô€Fð ×ÑØœ j¸ðOð ô ð ×ÑØ”C˜sð7ð ô ð ×ÑØˆk )Ø!¤'×"8Ñ"8Ð!9Ð:Ø6ð ô ð
 ˆ6×Ñ˜dÐ#€Dà‡}�}˜
Ò"Ø2‰ä�t—}‘}Ó%ˆô ‡|�|�wÒ =¼¿¹Ñ#CØ‰àˆÜð 2Ü29×2HÑ2HÐ1Ið JØ�Yð <ð =C¸8ð Dðó 	÷ 
‰‹ð ð „C„GØ„C„Gä
�/‰/˜$Ÿ-™-¸Ô
>€Cð	Ø�8Š8ä�C˜Ÿ™°5Ö9ô /¨sÓ3ˆGØ×Ñ˜V¨RÐÔ0à�	‰	Œä‡H�HˆQ…Køð 	�	‰	�ús   Ä1AF ÆF,Ú__main__r   )T)r1   r   r   Úargparser   Úcoder   Útextwrapr   r	   r   rS   r   Úargv© r&   r   ú<module>rZ      sT   ðñó Û 
å #Ý #Ý óô,Ð1ô ò8:ðz ˆzÒÙˆ�‰�!�"ˆÕð r&   