
    F\hu                         S r SSKrSSKrSSKJr  SSKJr  SSKJr  SS jr	 " S S\5      r
S	 r\S
:X  a  \" \R                  SS 5        gg)zA 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                     U R                  U5       H  n[        U5        M     g! [        R                   a  n[	        U5      R
                  n [        U SUR                   SU 3[        R                  S9  O-! [         a     [        U SU 3[        R                  S9   Of = fU(       d  [        R                  " S5         SnAg SnAgSnAff = f)zHelper 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.13/sqlite3/__main__.pyr	   r	      s    
99S>C#J "== !W	1RD1--.c!5CJJG 	1RD1#,SZZ0	1HHQKK s8   #& CC*A;:C;'B%"C$B%% CCc                   6   ^  \ rS rSrSrU 4S jrSS jrSrU =r$ )SqliteInteractiveConsole%   zA simple SQLite REPL.c                 X   > [         TU ]  5         Xl        UR                  5       U l        g )N)super__init___concursor_cur)self
connection	__class__s     r   r    !SqliteInteractiveConsole.__init__(   s#    	%%'	    c                    U=S:X  a    [        [        R                   5        g=S:X  a    [        S5        gS:X  a  [        R                  " S5        g [        R
                  " U5      (       d  g[        U R                  U5        g)zOverride 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   	runsource"SqliteInteractiveConsole.runsource-   sr     //02  78  
 	 11&99		6*r(   )r!   r#   )z<input>single)	r   
__module____qualname____firstlineno____doc__r    r/   __static_attributes____classcell__)r&   s   @r   r   r   %   s    (
 r(   r   c            	      r   [        SSS9nUR                  S[        SSSS9  UR                  S	[        SS
S9  UR                  SSSS[        R                   3SS9  UR
                  " U 6 n U R                  S:X  a  SnO[        U R                  5      n[        R                  S:X  a  S[        R                  ;  a  SnOSn[        S[        R                   SU SU S35      R                  5       nS[        l        S[        l        [        R                  " U R                  S S9n U R                   (       a  [#        XPR                   SS9  O [%        U5      n S S KnUR+                  US!S"9  UR-                  5         [        R.                  " S 5        g ! [(         a     NCf = f! UR-                  5         f = f)#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   r=   r>   z-vz	--versionversionzSQLite version z'Print underlying SQLite library version)actionr?   r>   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   r    )exitmsg)r   add_argumentstrr   r*   
parse_argsr-   reprr   platformmodulesr   stripps1ps2connectr   r	   r   readlineImportErrorinteractcloser   )argsparserdb_nameeofkeybannerconconsolerO   s           r   mainrZ   A   s   ( F jO   Cs7   k)!'"8"8!9:6  
 d#D}}
"2t}}% ||w=#C 2292H2H1I JY < =C8 D 	 
  CGCG
//$--
>C88C59 /s3G VR0		HHQK   			s0   '1F$ F F$ 
F!F$  F!!F$ $F6__main__r   )T)r5   r   r   argparser   coder   textwrapr   r	   r   rZ   r   argv r(   r   <module>ra      sT     
 # # ,1 8>B z!" r(   