RhdZddlZddlZddlmZddlmZddlmZd dZ GddeZ d Z e d k(re ejd dyy) 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 |j|D] }t|y#tj$r}t |j } t|d|j d|tjn/#t$r#t|d|tjYnwxYw|stjdYd}~yYd}~yd}~wwxYw)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) executeprintsqlite3Errortype__name__sqlite_errornamesysstderrAttributeErrorexit)csqlsuppress_errorsrowetps '/usr/lib/python3.12/sqlite3/__main__.pyr r s 99S> C #J  == !W   1 RD1--.c!5CJJ G 1 RD1#,SZZ 0 1 HHQKK s8!$CC  -A;:C ;)B'$C &B''C  Cc*eZdZdZfdZddZxZS)SqliteInteractiveConsolezA simple SQLite REPL.cZt|||_|j|_y)N)super__init___concursor_cur)self connection __class__s rrz!SqliteInteractiveConsole.__init__(s%  %%' c|xdk(rttjyxdk(r tdydk(rtjdy tj |syt |j|y)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.helpzEnter SQL code and press enter.z.quitrTF)r r sqlite_versionrrcomplete_statementr r")r#sourcefilenamesymbols r runsourcez"SqliteInteractiveConsole.runsource-so //0278   11&9 6*r&)zsingle)r __module__ __qualname____doc__rr- __classcell__)r%s@rrr%s( r&rc ^tdd}|jdtddd|jd tdd |jd d ddtjd|j |}|j dk(rd}nt|j }tjdk(rdtjvrd}nd}tdtjd|d|dj}dt_ dt_tj|j d} |j rt#||j dnt%|}|j'|d !|j)tj*d"y#|j)wxYw)#NzPython sqlite3 CLIzpython -m sqlite3) descriptionprogr+z:memory:?zrSQLite database to open (defaults to ':memory:'). A new database is created if the file does not previously exist.)r defaultnargshelprzAAn SQL query to execute. Any returned rows are printed to stdout.)r r8r9z-vz --versionversionzSQLite version z'Print underlying SQLite library version)actionr:r9za transient in-memory databasewin32z idlelib.runzCTRL-ZzCTRL-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. zsqlite> z ... )isolation_levelF)r)exitmsgr)r add_argumentstrr r( parse_argsr+reprrplatformmodulesrstripps1ps2connectrr rinteractcloser)argsparserdb_nameeofkeybannerconconsoles rmainrSAs ( F j O  Cs 7  k)!'"8"8!9: 6 6  d #D }} "2t}}% ||w= #C 2292H2H1IJY<=C8D    CGCG //$-- >C  88 C5 9/s3G   VR  0 HHQK s 1AFF,__main__r)T)r1r rargparsercodertextwraprr rrSrargvr&rrZsT  ##,18:z z!"r&