File: shell.html

package info (click to toggle)
python-apsw 3.46.0.1-1
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,684 kB
  • sloc: python: 13,125; ansic: 12,334; javascript: 911; makefile: 10; sh: 7
file content (1158 lines) | stat: -rw-r--r-- 105,110 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./">
<head>
  <meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>Shell &mdash; APSW 3.46.0.1 documentation</title>
      <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=72bcf2f2" />
      <link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" />
      <link rel="stylesheet" type="text/css" href="_static/apsw.css?v=3c7e2631" />

  
    <link rel="shortcut icon" href="_static/favicon.ico"/>
  <!--[if lt IE 9]>
    <script src="_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
        <script src="_static/jquery.js?v=5d32c60e"></script>
        <script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
        <script src="_static/documentation_options.js?v=d98f5d2b"></script>
        <script src="_static/doctools.js?v=9a2dae69"></script>
        <script src="_static/sphinx_highlight.js?v=dc90522c"></script>
    <script src="_static/js/theme.js"></script>
    <link rel="author" title="About these documents" href="about.html" />
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="copyright" title="Copyright" href="copyright.html" />
    <link rel="next" title="Best Practice" href="bestpractice.html" />
    <link rel="prev" title="Virtual File System (VFS)" href="vfs.html" /> 
</head>

<body class="wy-body-for-nav"> 
  <div class="wy-grid-for-nav">
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search" >

          
          
          <a href="index.html" class="icon icon-home">
            APSW
              <img src="_static/apswlogo.png" class="logo" alt="Logo"/>
          </a>
              <div class="version">
                3.46.0.1
              </div>
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>
        </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="about.html">About</a></li>
<li class="toctree-l1"><a class="reference internal" href="tips.html">Tips</a></li>
<li class="toctree-l1"><a class="reference internal" href="example.html">Example/Tour</a></li>
<li class="toctree-l1"><a class="reference internal" href="install.html">Installation and customization</a></li>
<li class="toctree-l1"><a class="reference internal" href="extensions.html">Extensions</a></li>
<li class="toctree-l1"><a class="reference internal" href="apsw.html">APSW Module</a></li>
<li class="toctree-l1"><a class="reference internal" href="connection.html">Connections to a database</a></li>
<li class="toctree-l1"><a class="reference internal" href="cursor.html">Cursors (executing SQL)</a></li>
<li class="toctree-l1"><a class="reference internal" href="blob.html">Blob Input/Output</a></li>
<li class="toctree-l1"><a class="reference internal" href="backup.html">Backup</a></li>
<li class="toctree-l1"><a class="reference internal" href="vtable.html">Virtual Tables</a></li>
<li class="toctree-l1"><a class="reference internal" href="vfs.html">Virtual File System (VFS)</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Shell</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#notes">Notes</a></li>
<li class="toctree-l2"><a class="reference internal" href="#command-line-usage">Command Line Usage</a></li>
<li class="toctree-l2"><a class="reference internal" href="#programmatic-usage">Programmatic Usage</a></li>
<li class="toctree-l2"><a class="reference internal" href="#commands">Commands</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#autoimport-filename-table">autoimport FILENAME ?TABLE?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#backup-db-file">backup ?DB? FILE</a></li>
<li class="toctree-l3"><a class="reference internal" href="#bail-on-off">bail ON|OFF</a></li>
<li class="toctree-l3"><a class="reference internal" href="#cd-dir">cd ?DIR?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#changes-on-off">changes ON|OFF</a></li>
<li class="toctree-l3"><a class="reference internal" href="#close">close</a></li>
<li class="toctree-l3"><a class="reference internal" href="#colour-scheme">colour SCHEME</a></li>
<li class="toctree-l3"><a class="reference internal" href="#connection-number">connection ?NUMBER?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#databases">databases</a></li>
<li class="toctree-l3"><a class="reference internal" href="#dbconfig-name-value">dbconfig ?NAME VALUE?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#dbinfo-name">dbinfo ?NAME?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#dump-table-table">dump ?TABLE? [TABLE…]</a></li>
<li class="toctree-l3"><a class="reference internal" href="#echo-on-off">echo ON|OFF</a></li>
<li class="toctree-l3"><a class="reference internal" href="#encoding-encoding">encoding ENCODING</a></li>
<li class="toctree-l3"><a class="reference internal" href="#exceptions-on-off">exceptions ON|OFF</a></li>
<li class="toctree-l3"><a class="reference internal" href="#exit-code">exit ?CODE?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#find-value-table">find value ?TABLE?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#header-s-on-off">header(s) ON|OFF</a></li>
<li class="toctree-l3"><a class="reference internal" href="#help-command">help ?COMMAND?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#import-file-table">import FILE TABLE</a></li>
<li class="toctree-l3"><a class="reference internal" href="#indices-table">indices TABLE</a></li>
<li class="toctree-l3"><a class="reference internal" href="#load-file-entry">load FILE ?ENTRY?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#log-on-off">log ON|OFF</a></li>
<li class="toctree-l3"><a class="reference internal" href="#mode-mode-options">mode MODE ?OPTIONS?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#nullvalue-string">nullvalue STRING</a></li>
<li class="toctree-l3"><a class="reference internal" href="#open-options-file">open ?OPTIONS? ?FILE?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#output-filename">output FILENAME</a></li>
<li class="toctree-l3"><a class="reference internal" href="#parameter-cmd">parameter CMD …</a></li>
<li class="toctree-l3"><a class="reference internal" href="#print-string">print STRING</a></li>
<li class="toctree-l3"><a class="reference internal" href="#prompt-main-continue">prompt MAIN ?CONTINUE?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#py-python">py ?PYTHON?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#read-filename">read FILENAME</a></li>
<li class="toctree-l3"><a class="reference internal" href="#restore-db-file">restore ?DB? FILE</a></li>
<li class="toctree-l3"><a class="reference internal" href="#schema-table-table">schema ?TABLE? [TABLE…]</a></li>
<li class="toctree-l3"><a class="reference internal" href="#separator-string">separator STRING</a></li>
<li class="toctree-l3"><a class="reference internal" href="#shell-cmd-args">shell CMD ARGS…</a></li>
<li class="toctree-l3"><a class="reference internal" href="#show">show</a></li>
<li class="toctree-l3"><a class="reference internal" href="#tables-pattern">tables ?PATTERN?</a></li>
<li class="toctree-l3"><a class="reference internal" href="#timeout-ms">timeout MS</a></li>
<li class="toctree-l3"><a class="reference internal" href="#timer-on-off">timer ON|OFF</a></li>
<li class="toctree-l3"><a class="reference internal" href="#version">version</a></li>
<li class="toctree-l3"><a class="reference internal" href="#vfsinfo">vfsinfo</a></li>
<li class="toctree-l3"><a class="reference internal" href="#vfslist">vfslist</a></li>
<li class="toctree-l3"><a class="reference internal" href="#vfsname">vfsname</a></li>
<li class="toctree-l3"><a class="reference internal" href="#width-num-num">width NUM NUM …</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#shell-class">Shell class</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#apsw.shell.Shell"><code class="docutils literal notranslate"><span class="pre">Shell</span></code></a><ul>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.Error"><code class="docutils literal notranslate"><span class="pre">Shell.Error</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.PositionRow"><code class="docutils literal notranslate"><span class="pre">Shell.PositionRow</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.Row"><code class="docutils literal notranslate"><span class="pre">Shell.Row</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.cmdloop"><code class="docutils literal notranslate"><span class="pre">Shell.cmdloop()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.complete"><code class="docutils literal notranslate"><span class="pre">Shell.complete()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.complete_command"><code class="docutils literal notranslate"><span class="pre">Shell.complete_command()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.complete_sql"><code class="docutils literal notranslate"><span class="pre">Shell.complete_sql()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.db"><code class="docutils literal notranslate"><span class="pre">Shell.db</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.display_timing"><code class="docutils literal notranslate"><span class="pre">Shell.display_timing()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.fixup_backslashes"><code class="docutils literal notranslate"><span class="pre">Shell.fixup_backslashes()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.get_complete_line"><code class="docutils literal notranslate"><span class="pre">Shell.get_complete_line()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.get_line"><code class="docutils literal notranslate"><span class="pre">Shell.get_line()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.get_resource_usage"><code class="docutils literal notranslate"><span class="pre">Shell.get_resource_usage()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.handle_exception"><code class="docutils literal notranslate"><span class="pre">Shell.handle_exception()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.handle_interrupt"><code class="docutils literal notranslate"><span class="pre">Shell.handle_interrupt()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.log_handler"><code class="docutils literal notranslate"><span class="pre">Shell.log_handler()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.pop_input"><code class="docutils literal notranslate"><span class="pre">Shell.pop_input()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.pop_output"><code class="docutils literal notranslate"><span class="pre">Shell.pop_output()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.process_args"><code class="docutils literal notranslate"><span class="pre">Shell.process_args()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.process_command"><code class="docutils literal notranslate"><span class="pre">Shell.process_command()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.process_complete_line"><code class="docutils literal notranslate"><span class="pre">Shell.process_complete_line()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.process_sql"><code class="docutils literal notranslate"><span class="pre">Shell.process_sql()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.process_unknown_args"><code class="docutils literal notranslate"><span class="pre">Shell.process_unknown_args()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.push_input"><code class="docutils literal notranslate"><span class="pre">Shell.push_input()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.push_output"><code class="docutils literal notranslate"><span class="pre">Shell.push_output()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.set_encoding"><code class="docutils literal notranslate"><span class="pre">Shell.set_encoding()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.usage"><code class="docutils literal notranslate"><span class="pre">Shell.usage()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.write"><code class="docutils literal notranslate"><span class="pre">Shell.write()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.write_error"><code class="docutils literal notranslate"><span class="pre">Shell.write_error()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.shell.Shell.write_value"><code class="docutils literal notranslate"><span class="pre">Shell.write_value()</span></code></a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#apsw.shell.main"><code class="docutils literal notranslate"><span class="pre">main()</span></code></a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="bestpractice.html">Best Practice</a></li>
<li class="toctree-l1"><a class="reference internal" href="ext.html">Various interesting and useful bits of functionality</a></li>
<li class="toctree-l1"><a class="reference internal" href="exceptions.html">Exceptions and Errors</a></li>
<li class="toctree-l1"><a class="reference internal" href="execution.html">Execution and tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="dbapi.html">DBAPI notes</a></li>
<li class="toctree-l1"><a class="reference internal" href="pysqlite.html">sqlite3 module differences</a></li>
<li class="toctree-l1"><a class="reference internal" href="benchmarking.html">Benchmarking</a></li>
<li class="toctree-l1"><a class="reference internal" href="copyright.html">Copyright and License</a></li>
<li class="toctree-l1"><a class="reference internal" href="changes.html">Change History</a></li>
<li class="toctree-l1"><a class="reference internal" href="py-modindex.html">Module Index</a></li>
<li class="toctree-l1"><a class="reference internal" href="genindex.html">Index</a></li>
</ul>

        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="index.html">APSW</a>
      </nav>

      <div class="wy-nav-content">
        <div class="rst-content style-external-links">
          <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="index.html" class="icon icon-home" aria-label="Home"></a></li>
      <li class="breadcrumb-item active">Shell</li>
      <li class="wy-breadcrumbs-aside">
            <a href="_sources/shell.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul><div class="rst-breadcrumbs-buttons" role="navigation" aria-label="Sequential page navigation">
        <a href="vfs.html" class="btn btn-neutral float-left" title="Virtual File System (VFS)" accesskey="p"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="bestpractice.html" class="btn btn-neutral float-right" title="Best Practice" accesskey="n">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
  </div>
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
             
  <section id="shell">
<span id="id1"></span><h1>Shell<a class="headerlink" href="#shell" title="Link to this heading"></a></h1>
<p>The shell provides a convenient way for you to interact with SQLite,
perform administration, and supply SQL for execution.  It is modelled
after the <a class="reference external" href="https://sqlite.org/cli.html">shell that comes with SQLite</a> which doesn’t interoperate with Python.</p>
<p>Notable improvements include:</p>
<ul class="simple">
<li><p>You can invoke this shell programmatically - very useful for
development and debugging</p></li>
<li><p>Output is in colour</p></li>
<li><p>Tab completion is available</p></li>
<li><p>Nicer text dump output, including metadata like user_version</p></li>
<li><p>All open APSW <a class="reference internal" href="connection.html#apsw.Connection" title="apsw.Connection"><code class="xref py py-class docutils literal notranslate"><span class="pre">connections</span></code></a> are available
and you can switch between them</p></li>
<li><p><a class="reference internal" href="#shell-cmd-py"><span class="std std-ref">.py command</span></a> gets you a Python REPL or
runs one line of Python code</p></li>
<li><p>Very useful <a class="reference internal" href="#shell-cmd-autoimport"><span class="std std-ref">autoimport</span></a> and <a class="reference internal" href="#shell-cmd-find"><span class="std std-ref">find</span></a> commands</p></li>
</ul>
<section id="notes">
<h2>Notes<a class="headerlink" href="#notes" title="Link to this heading"></a></h2>
<p>To interrupt the shell press Control-C. (On Windows if you press
Control-Break then the program will be terminated.)</p>
<p>For Windows users you won’t have command line editing and completion
unless you install a <a class="reference external" href="https://docs.python.org/3/library/readline.html#module-readline" title="(in Python v3.12)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">readline</span> <span class="pre">module</span></code></a>. You can pip
install <a class="reference external" href="https://pypi.org/project/pyreadline3/">pyreadline3</a> to get
full functionality.</p>
<p>For Windows users, the builtin console support for colour is used.  It
is enabled by default in current versions of Windows, and a registry
key enables for older versions <a class="reference external" href="https://github.com/kiedtl/winfetch/wiki/ANSI-Colors">(details)</a>.</p>
</section>
<section id="command-line-usage">
<h2>Command Line Usage<a class="headerlink" href="#command-line-usage" title="Link to this heading"></a></h2>
<p>You can use the shell directly from the command line.</p>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>Usage: python3 -m apsw [OPTIONS] FILENAME [SQL|CMD] [SQL|CMD]...
FILENAME is the name of a SQLite database. A new database is
created if the file does not exist. If omitted or an empty
string then an in-memory database is created.
OPTIONS include:

   -init filename       read/process named file
   -echo                print commands before execution
   -[no]header          turn headers on or off
   -bail                stop after hitting the first error
   -interactive         force interactive I/O (command editing and colour)
   -batch               force batch I/O (no banners or editing)
   -column              set output mode to &#39;column&#39;
   -csv                 set output mode to &#39;csv&#39;
   -html                set output mode to &#39;html&#39;
   -line                set output mode to &#39;line&#39;
   -list                set output mode to &#39;list&#39;
   -python              set output mode to &#39;python&#39;
   -jsonl               set output mode to &#39;jsonl&#39;
   -separator &#39;x&#39;       set output field separator (|)
   -nullvalue &#39;text&#39;    set text string for NULL values
   -version             show SQLite version
   -encoding &#39;name&#39;     the encoding to use for files
                        opened via .import, .read &amp; .output
   -nocolour            disables interactive colour output
</pre></div>
</div>
</section>
<section id="programmatic-usage">
<h2>Programmatic Usage<a class="headerlink" href="#programmatic-usage" title="Link to this heading"></a></h2>
<p>You can also use the shell programmatically (or even interactively and
programmatically at the same time).  See the <a class="reference internal" href="example.html#example-shell"><span class="std std-ref">example</span></a> for using the API.</p>
<p>To quickly invoke the shell similar to the Python debugger, do this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">apsw</span><span class="o">.</span><span class="n">shell</span><span class="o">.</span><span class="n">Shell</span><span class="p">(</span><span class="n">db</span><span class="o">=</span><span class="n">database_of_interest</span><span class="p">)</span><span class="o">.</span><span class="n">cmdloop</span><span class="p">()</span>
</pre></div>
</div>
<p>You can use <a class="reference internal" href="#shell-cmd-connection"><span class="std std-ref">.connection</span></a> to switch
amongst connections.  Press Control-D at the prompt (Control-Z on
Windows) will exit the shell.</p>
</section>
<section id="commands">
<span id="shell-commands"></span><h2>Commands<a class="headerlink" href="#commands" title="Link to this heading"></a></h2>
<p>In addition to executing SQL, these are the commands available with
their description.  Commands are distinguished from SQL by having a
leading <code class="docutils literal notranslate"><span class="pre">.</span></code> (period) - for example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">.</span><span class="n">help</span>
<span class="o">.</span><span class="n">mode</span> <span class="n">qbox</span>
<span class="o">.</span><span class="n">find</span> <span class="n">winchester</span>
</pre></div>
</div>
<table class="hlist"><tr><td><ul class="simple">
<li><p><a class="reference internal" href="#shell-cmd-autoimport"><span class="std std-ref">autoimport</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-backup"><span class="std std-ref">backup</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-bail"><span class="std std-ref">bail</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-cd"><span class="std std-ref">cd</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-changes"><span class="std std-ref">changes</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-close"><span class="std std-ref">close</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-colour"><span class="std std-ref">colour</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-connection"><span class="std std-ref">connection</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-databases"><span class="std std-ref">databases</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-dbconfig"><span class="std std-ref">dbconfig</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-dbinfo"><span class="std std-ref">dbinfo</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-dump"><span class="std std-ref">dump</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-echo"><span class="std std-ref">echo</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-encoding"><span class="std std-ref">encoding</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-exceptions"><span class="std std-ref">exceptions</span></a></p></li>
</ul>
</td><td><ul class="simple">
<li><p><a class="reference internal" href="#shell-cmd-exit"><span class="std std-ref">exit</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-find"><span class="std std-ref">find</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-header"><span class="std std-ref">header</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-help"><span class="std std-ref">help</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-import"><span class="std std-ref">import</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-indices"><span class="std std-ref">indices</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-load"><span class="std std-ref">load</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-log"><span class="std std-ref">log</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-mode"><span class="std std-ref">mode</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-nullvalue"><span class="std std-ref">nullvalue</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-open"><span class="std std-ref">open</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-output"><span class="std std-ref">output</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-parameter"><span class="std std-ref">parameter</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-print"><span class="std std-ref">print</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-prompt"><span class="std std-ref">prompt</span></a></p></li>
</ul>
</td><td><ul class="simple">
<li><p><a class="reference internal" href="#shell-cmd-py"><span class="std std-ref">py</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-read"><span class="std std-ref">read</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-restore"><span class="std std-ref">restore</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-schema"><span class="std std-ref">schema</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-separator"><span class="std std-ref">separator</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-shell"><span class="std std-ref">shell</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-show"><span class="std std-ref">show</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-tables"><span class="std std-ref">tables</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-timeout"><span class="std std-ref">timeout</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-timer"><span class="std std-ref">timer</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-version"><span class="std std-ref">version</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-vfsinfo"><span class="std std-ref">vfsinfo</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-vfslist"><span class="std std-ref">vfslist</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-vfsname"><span class="std std-ref">vfsname</span></a></p></li>
<li><p><a class="reference internal" href="#shell-cmd-width"><span class="std std-ref">width</span></a></p></li>
</ul>
</td></tr></table>
<section id="autoimport-filename-table">
<span id="index-0"></span><span id="shell-cmd-autoimport"></span><h3>autoimport FILENAME ?TABLE?<a class="headerlink" href="#autoimport-filename-table" title="Link to this heading"></a></h3>
<p><em>Imports filename creating a table and automatically working out separators and data types (alternative to .import command)</em></p>
<p>The import command requires that you precisely pre-setup the table and schema,
and set the data separators (eg commas or tabs).  This command figures out the
separator and csv dialect automatically.  There must be at least two columns and
two rows.</p>
<p>If the table is not specified then the basename of the file will be used.</p>
<p>Additionally the type of the contents of each column is also deduced - for
example if it is a number or date.  Empty values are turned into nulls.  Dates
are normalized into <code class="docutils literal notranslate"><span class="pre">YYYY</span></code>-<code class="docutils literal notranslate"><span class="pre">MM</span></code>-<code class="docutils literal notranslate"><span class="pre">DD</span></code> format and DateTime are normalized
into ISO8601 format to allow easy sorting and searching.  4 digit years must be
used to detect dates.  US (swapped day and month) versus rest of the world is
also detected providing there is at least one value that resolves the ambiguity.</p>
<p>Care is taken to ensure that columns looking like numbers are only treated as
numbers if they do not have unnecessary leading zeroes or plus signs.  This is
to avoid treating phone numbers and similar number like strings as integers.</p>
<p>This command can take quite some time on large files as they are effectively
imported twice.  The first time is to determine the format and the types for
each column while the second pass actually imports the data.</p>
</section>
<section id="backup-db-file">
<span id="index-1"></span><span id="shell-cmd-backup"></span><h3>backup ?DB? FILE<a class="headerlink" href="#backup-db-file" title="Link to this heading"></a></h3>
<p><em>Backup DB (default “main”) to FILE</em></p>
<p>Copies the contents of the current database to <code class="docutils literal notranslate"><span class="pre">FILE</span></code> overwriting whatever was
in <code class="docutils literal notranslate"><span class="pre">FILE</span></code>.  If you have attached databases then you can specify their name
instead of the default of “main”.</p>
<p>The backup is done at the page level - SQLite copies the pages as is.  There is
no round trip through SQL code.</p>
</section>
<section id="bail-on-off">
<span id="index-2"></span><span id="shell-cmd-bail"></span><h3>bail ON|OFF<a class="headerlink" href="#bail-on-off" title="Link to this heading"></a></h3>
<p><em>Stop after hitting an error (default OFF)</em></p>
<p>If an error is encountered while processing commands or SQL then exit.  (Note
this is different than SQLite shell which only exits for errors in SQL.)</p>
</section>
<section id="cd-dir">
<span id="index-3"></span><span id="shell-cmd-cd"></span><h3>cd ?DIR?<a class="headerlink" href="#cd-dir" title="Link to this heading"></a></h3>
<p><em>Changes current directory</em></p>
<p>If no directory supplied then change to home directory</p>
</section>
<section id="changes-on-off">
<span id="index-4"></span><span id="shell-cmd-changes"></span><h3>changes ON|OFF<a class="headerlink" href="#changes-on-off" title="Link to this heading"></a></h3>
<p><em>Show changes from last SQL and total changes (default OFF)</em></p>
<p>After executing SQL that makes changes, the number of affected rows is displayed
as well as a running count of all changes.</p>
</section>
<section id="close">
<span id="index-5"></span><span id="shell-cmd-close"></span><h3>close<a class="headerlink" href="#close" title="Link to this heading"></a></h3>
<p><em>Closes the current database</em></p>
<p>Use .open to open a database, or .connection to switch to another connection</p>
</section>
<section id="colour-scheme">
<span id="index-6"></span><span id="shell-cmd-colour"></span><h3>colour SCHEME<a class="headerlink" href="#colour-scheme" title="Link to this heading"></a></h3>
<p><em>Selects a colour scheme from default, off</em></p>
<p>If using a colour terminal in interactive mode then output is automatically
coloured to make it more readable.  Use <code class="docutils literal notranslate"><span class="pre">off</span></code> to turn off colour, and no name
or <code class="docutils literal notranslate"><span class="pre">default</span></code> for the default colour scheme.</p>
</section>
<section id="connection-number">
<span id="index-7"></span><span id="shell-cmd-connection"></span><h3>connection ?NUMBER?<a class="headerlink" href="#connection-number" title="Link to this heading"></a></h3>
<p><em>List connections, or switch active connection</em></p>
<p>This covers all connections, not just those started in this shell.  Closed
connections are not shown.</p>
</section>
<section id="databases">
<span id="index-8"></span><span id="shell-cmd-databases"></span><h3>databases<a class="headerlink" href="#databases" title="Link to this heading"></a></h3>
<p><em>Lists names and files of attached databases</em></p>
</section>
<section id="dbconfig-name-value">
<span id="index-9"></span><span id="shell-cmd-dbconfig"></span><h3>dbconfig ?NAME VALUE?<a class="headerlink" href="#dbconfig-name-value" title="Link to this heading"></a></h3>
<p><em>Show all dbconfig, or set a specific one</em></p>
<p>With no arguments lists all settings.  Supply a name and integer value to
change.  For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">.</span><span class="n">dbconfig</span> <span class="n">enable_fkey</span> <span class="mi">1</span>
</pre></div>
</div>
</section>
<section id="dbinfo-name">
<span id="index-10"></span><span id="shell-cmd-dbinfo"></span><h3>dbinfo ?NAME?<a class="headerlink" href="#dbinfo-name" title="Link to this heading"></a></h3>
<p><em>Shows summary and file information about the database</em></p>
<p>This includes the numbers of tables, indices etc, as well as fields from the
files as returned by <a class="reference internal" href="ext.html#apsw.ext.dbinfo" title="apsw.ext.dbinfo"><code class="xref py py-func docutils literal notranslate"><span class="pre">apsw.ext.dbinfo()</span></code></a>.</p>
<p><code class="docutils literal notranslate"><span class="pre">NAME</span></code> defaults to <code class="docutils literal notranslate"><span class="pre">main</span></code>, and can be the attached name of a database.</p>
</section>
<section id="dump-table-table">
<span id="index-11"></span><span id="shell-cmd-dump"></span><h3>dump ?TABLE? [TABLE…]<a class="headerlink" href="#dump-table-table" title="Link to this heading"></a></h3>
<p><em>Dumps all or specified tables in SQL text format</em></p>
<p>The table name is treated as like pattern so you can use <code class="docutils literal notranslate"><span class="pre">%</span></code> as a wildcard.
You can use dump to make a text based backup of the database.  It is also useful
for comparing differences or making the data available to other databases.
Indices and triggers for the table(s) are also dumped.  Finally views matching
the table pattern name are dumped.</p>
<p>Note that if you are dumping virtual tables such as used by the FTS5 module then
they may use other tables to store information.  For example if you create a
FTS5 table named <em>recipes</em> then it also creates <em>recipes_content</em>,
<em>recipes_segdir</em> etc.  Consequently to dump this example correctly use:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">.</span><span class="n">dump</span> <span class="n">recipes</span> <span class="n">recipes_</span><span class="o">%</span>
</pre></div>
</div>
<p>If the database is empty or no tables/views match then there is no output.</p>
</section>
<section id="echo-on-off">
<span id="index-12"></span><span id="shell-cmd-echo"></span><h3>echo ON|OFF<a class="headerlink" href="#echo-on-off" title="Link to this heading"></a></h3>
<p><em>If ON then each SQL statement or command is printed before execution (default OFF)</em></p>
<p>The SQL statement or command is sent to error output so that it is not
intermingled with regular output.</p>
</section>
<section id="encoding-encoding">
<span id="index-13"></span><span id="shell-cmd-encoding"></span><h3>encoding ENCODING<a class="headerlink" href="#encoding-encoding" title="Link to this heading"></a></h3>
<p><em>Set the encoding used for new files opened via .output and imports</em></p>
<p>SQLite and APSW/Python work internally using Unicode and characters. Files
however are a sequence of bytes.  An encoding describes how to convert between
bytes and characters.  The default encoding is utf8 and that is generally the
best value to use when other programs give you a choice.</p>
<p>You can also specify an error handler.  For example <cite>cp437:replace</cite> will use
code page 437 and any Unicode codepoints not present in cp437 will be replaced
(typically with something like a question mark).  Other error handlers include
<cite>ignore</cite>, <cite>strict</cite> (default) and <cite>xmlcharrefreplace</cite>.</p>
<p>This command affects files opened after setting the encoding as well as imports.</p>
</section>
<section id="exceptions-on-off">
<span id="index-14"></span><span id="shell-cmd-exceptions"></span><h3>exceptions ON|OFF<a class="headerlink" href="#exceptions-on-off" title="Link to this heading"></a></h3>
<p><em>If ON then detailed tracebacks are shown on exceptions (default OFF)</em></p>
<p>Normally when an exception occurs the error string only is displayed.  However
it is sometimes useful to get a full traceback.  An example would be when you
are developing virtual tables and using the shell to exercise them.  In addition
to displaying each stack frame, the local variables within each frame are also
displayed.</p>
</section>
<section id="exit-code">
<span id="index-15"></span><span id="shell-cmd-exit"></span><h3>exit ?CODE?<a class="headerlink" href="#exit-code" title="Link to this heading"></a></h3>
<p><em>Exit this program with optional exit code</em></p>
</section>
<section id="find-value-table">
<span id="index-16"></span><span id="shell-cmd-find"></span><h3>find value ?TABLE?<a class="headerlink" href="#find-value-table" title="Link to this heading"></a></h3>
<p><em>Searches all columns of all tables for a value</em></p>
<p>The find command helps you locate data across your database for example to find
a string or any references to an id.</p>
<p>You can specify a like pattern to limit the search to a subset of tables (eg
specifying <code class="docutils literal notranslate"><span class="pre">CUSTOMER%</span></code> for all tables beginning with <code class="docutils literal notranslate"><span class="pre">CUSTOMER</span></code>).</p>
<p>The value will be treated as a string and/or integer if possible.  If value
contains <code class="docutils literal notranslate"><span class="pre">%</span></code> or <code class="docutils literal notranslate"><span class="pre">_</span></code> then it is also treated as a like pattern.</p>
<p>This command can take a long time to execute needing to scan all of the relevant
tables, rows, and columns.</p>
</section>
<section id="header-s-on-off">
<span id="index-17"></span><span id="shell-cmd-header"></span><h3>header(s) ON|OFF<a class="headerlink" href="#header-s-on-off" title="Link to this heading"></a></h3>
<p><em>Display the column names in output (default OFF)</em></p>
</section>
<section id="help-command">
<span id="index-18"></span><span id="shell-cmd-help"></span><h3>help ?COMMAND?<a class="headerlink" href="#help-command" title="Link to this heading"></a></h3>
<p><em>Shows list of commands and their usage</em></p>
<p>If <code class="docutils literal notranslate"><span class="pre">COMMAND</span></code> is specified then shows detail about that <code class="docutils literal notranslate"><span class="pre">COMMAND</span></code>. <code class="docutils literal notranslate"><span class="pre">.help</span>
<span class="pre">all</span></code> will show detailed help about all commands.</p>
</section>
<section id="import-file-table">
<span id="index-19"></span><span id="shell-cmd-import"></span><h3>import FILE TABLE<a class="headerlink" href="#import-file-table" title="Link to this heading"></a></h3>
<p><em>Imports separated data from FILE into TABLE</em></p>
<p>Reads data from the file into the named table using the current separator and
encoding.  For example if the separator is currently a comma then the file
should be CSV (comma separated values).</p>
<p>All values read in are supplied to SQLite as strings.  If you want SQLite to
treat them as other types then declare your columns appropriately.  For example
declaring a column <code class="docutils literal notranslate"><span class="pre">REAL</span></code> will result in the values being stored as floating
point if they can be safely converted.</p>
<p>Another alternative is to create a temporary table, insert the values into that
and then use casting.:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">CREATE</span> <span class="n">TEMPORARY</span> <span class="n">TABLE</span> <span class="n">import</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="n">b</span><span class="p">,</span><span class="n">c</span><span class="p">);</span>
<span class="o">.</span><span class="kn">import</span> <span class="nn">filename</span> <span class="kn">import</span>
<span class="nn">CREATE</span> <span class="n">TABLE</span> <span class="n">final</span> <span class="n">AS</span> <span class="n">SELECT</span> <span class="n">cast</span><span class="p">(</span><span class="n">a</span> <span class="k">as</span> <span class="n">BLOB</span><span class="p">),</span> <span class="n">cast</span><span class="p">(</span><span class="n">b</span> <span class="k">as</span> <span class="n">INTEGER</span><span class="p">),</span>
     <span class="n">cast</span><span class="p">(</span><span class="n">c</span> <span class="k">as</span> <span class="n">CHAR</span><span class="p">)</span> <span class="kn">from</span> <span class="nn">import</span><span class="p">;</span>
<span class="n">DROP</span> <span class="n">TABLE</span> <span class="n">import</span><span class="p">;</span>
</pre></div>
</div>
<p>You can also get more sophisticated using the SQL <code class="docutils literal notranslate"><span class="pre">CASE</span></code> operator.  For
example this will turn zero length strings into null:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">SELECT</span> <span class="n">CASE</span> <span class="n">col</span> <span class="n">WHEN</span> <span class="s1">&#39;&#39;</span> <span class="n">THEN</span> <span class="n">null</span> <span class="n">ELSE</span> <span class="n">col</span> <span class="n">END</span> <span class="n">FROM</span> <span class="o">...</span>
</pre></div>
</div>
</section>
<section id="indices-table">
<span id="index-20"></span><span id="shell-cmd-indices"></span><h3>indices TABLE<a class="headerlink" href="#indices-table" title="Link to this heading"></a></h3>
<p><em>Lists all indices on table TABLE</em></p>
</section>
<section id="load-file-entry">
<span id="index-21"></span><span id="shell-cmd-load"></span><h3>load FILE ?ENTRY?<a class="headerlink" href="#load-file-entry" title="Link to this heading"></a></h3>
<p><em>Loads a SQLite extension library</em></p>
<p>Note: Extension loading may not be enabled in the SQLite library version you are
using.</p>
<p>By default sqlite3_extension_init is called in the library but you can specify
an alternate entry point.</p>
<p>If you get an error about the extension not being found you may need to
explicitly specify the directory.  For example if it is in the current directory
then use:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">.</span><span class="n">load</span> <span class="o">./</span><span class="n">extension</span><span class="o">.</span><span class="n">so</span>
</pre></div>
</div>
</section>
<section id="log-on-off">
<span id="index-22"></span><span id="shell-cmd-log"></span><h3>log ON|OFF<a class="headerlink" href="#log-on-off" title="Link to this heading"></a></h3>
<p><em>Shows SQLite log messages (default off)</em></p>
</section>
<section id="mode-mode-options">
<span id="index-23"></span><span id="shell-cmd-mode"></span><h3>mode MODE ?OPTIONS?<a class="headerlink" href="#mode-mode-options" title="Link to this heading"></a></h3>
<p><em>Sets output mode to one of box column columns csv html insert json jsonl line lines list python qbox table tabs tcl</em></p>
<p>box: Outputs using line drawing and auto sizing columns</p>
<p>columns: Items left aligned in space padded columns. They are truncated if they
do not fit. If the width hasn’t been specified for a column then 10 is used
unless the column name (header) is longer in which case that width is used. Use
the .width command to change column sizes.</p>
<p>csv: Items in csv format (comma separated). Use tabs mode for tab separated. You
can use the .separator command to use a different one after switching mode.
<code class="docutils literal notranslate"><span class="pre">A</span></code> separator of comma uses double quotes for quoting while other separators
do not do any quoting. The Python csv library used for this only supports single
character separators.</p>
<p>html: HTML table style</p>
<p>insert: Lines as SQL insert statements. The table name is “table” unless you
specified a different one as the second parameter to the .mode command.</p>
<p>json: Output a JSON array. Blobs are output as base64 encoded strings.</p>
<p>jsonl: Output as JSON objects, newline separated. Blobs are output as base64
encoded strings.</p>
<p>lines: One value per line in the form ‘column = value’ with a blank line between
rows.</p>
<p>list: All items on one line with separator</p>
<p>python: Tuples in Python source form for each row</p>
<p>qbox: Outputs using line drawing and auto sizing columns quoting values</p>
<p>table: Outputs using ascii line drawing and strongly sanitized text</p>
<p>tcl: Outputs TCL/C style strings using current separator</p>
</section>
<section id="nullvalue-string">
<span id="index-24"></span><span id="shell-cmd-nullvalue"></span><h3>nullvalue STRING<a class="headerlink" href="#nullvalue-string" title="Link to this heading"></a></h3>
<p><em>Print STRING in place of null values</em></p>
<p>This affects textual output modes like column and list and sets how SQL null
values are shown.  The default is a zero length string.  Insert mode and dumps
are not affected by this setting.  You can use double quotes to supply a zero
length string.  For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">.</span><span class="n">nullvalue</span> <span class="s2">&quot;&quot;</span>         <span class="c1"># the default</span>
<span class="o">.</span><span class="n">nullvalue</span> <span class="o">&lt;</span><span class="n">NULL</span><span class="o">&gt;</span>     <span class="c1"># rather obvious</span>
<span class="o">.</span><span class="n">nullvalue</span> <span class="s2">&quot; </span><span class="se">\\</span><span class="s2">t &quot;</span>     <span class="c1"># A tab surrounded by spaces</span>
</pre></div>
</div>
</section>
<section id="open-options-file">
<span id="index-25"></span><span id="shell-cmd-open"></span><h3>open ?OPTIONS? ?FILE?<a class="headerlink" href="#open-options-file" title="Link to this heading"></a></h3>
<p><em>Opens a database connection</em></p>
<p>Options are:</p>
<dl class="option-list">
<dt><kbd><span class="option">--wipe</span></kbd></dt>
<dd><p>Closes any existing connections in this process referring to
the same file  and deletes the database file, journals etc
before opening</p>
</dd>
<dt><kbd><span class="option">--vfs <var>VFS</var></span></kbd></dt>
<dd><p>Which vfs to use when opening</p>
</dd>
</dl>
<p>If <code class="docutils literal notranslate"><span class="pre">FILE</span></code> is omitted then a memory database is opened</p>
</section>
<section id="output-filename">
<span id="index-26"></span><span id="shell-cmd-output"></span><h3>output FILENAME<a class="headerlink" href="#output-filename" title="Link to this heading"></a></h3>
<p><em>Send output to FILENAME (or stdout)</em></p>
<p>If the <code class="docutils literal notranslate"><span class="pre">FILENAME</span></code> is <code class="docutils literal notranslate"><span class="pre">stdout</span></code> then output is sent to standard output from
when the shell was started.  The file is opened using the current encoding
(change with <code class="docutils literal notranslate"><span class="pre">encoding</span></code> command).</p>
</section>
<section id="parameter-cmd">
<span id="index-27"></span><span id="shell-cmd-parameter"></span><h3>parameter CMD …<a class="headerlink" href="#parameter-cmd" title="Link to this heading"></a></h3>
<p><em>Maintain named bindings you can use in your queries.</em></p>
<p>Specify a subcommand:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="nb">list</span>            <span class="o">--</span> <span class="n">shows</span> <span class="n">current</span> <span class="n">bindings</span>
<span class="n">clear</span>           <span class="o">--</span> <span class="n">deletes</span> <span class="nb">all</span> <span class="n">bindings</span>
<span class="n">unset</span> <span class="n">NAME</span>      <span class="o">--</span> <span class="n">deletes</span> <span class="n">named</span> <span class="n">binding</span>
<span class="nb">set</span> <span class="n">NAME</span> <span class="n">VALUE</span>  <span class="o">--</span> <span class="n">sets</span> <span class="n">binding</span> <span class="n">to</span> <span class="n">VALUE</span>
</pre></div>
</div>
<p>The value must be a valid SQL literal or expression.  For example <cite>3</cite> will be an
integer 3 while <code class="docutils literal notranslate"><span class="pre">'3'</span></code> will be a string.</p>
<p>Example::</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>.parameter set floor 10.99
.parameter set text &#39;Acme&#39;&#39;s Glove&#39;
SELECT * FROM sales WHERE price &gt; $floor AND description != $text;
</pre></div>
</div>
</section>
<section id="print-string">
<span id="index-28"></span><span id="shell-cmd-print"></span><h3>print STRING<a class="headerlink" href="#print-string" title="Link to this heading"></a></h3>
<p><em>print the literal STRING</em></p>
<p>If more than one argument is supplied then they are printed space separated.
You can use backslash escapes such as \n and \t.</p>
</section>
<section id="prompt-main-continue">
<span id="index-29"></span><span id="shell-cmd-prompt"></span><h3>prompt MAIN ?CONTINUE?<a class="headerlink" href="#prompt-main-continue" title="Link to this heading"></a></h3>
<p><em>Changes the prompts for first line and continuation lines</em></p>
<p>The default is to print ‘sqlite&gt; ‘ for the main prompt where you can enter a dot
command or a SQL statement.  If the SQL statement is not complete then you are
prompted for more using the continuation prompt which defaults to ‘ ..&gt; ‘.
Example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">.</span><span class="n">prompt</span> <span class="s2">&quot;command&gt; &quot;</span> <span class="s2">&quot;more command&gt; &quot;</span>
</pre></div>
</div>
<p>You can use backslash escapes such as \n and \t.</p>
</section>
<section id="py-python">
<span id="index-30"></span><span id="shell-cmd-py"></span><h3>py ?PYTHON?<a class="headerlink" href="#py-python" title="Link to this heading"></a></h3>
<p><em>Starts a python REPL or runs the Python statement provided</em></p>
<p>The namespace provided includes <code class="docutils literal notranslate"><span class="pre">apsw</span></code> for the module, <code class="docutils literal notranslate"><span class="pre">shell</span></code> for this
shell and <code class="docutils literal notranslate"><span class="pre">db</span></code> for the current database.</p>
<p>Using the .output command does not affect output from this command.  You can
write to <cite>shell.stdout</cite> and <cite>shell.stderr</cite>.</p>
</section>
<section id="read-filename">
<span id="index-31"></span><span id="shell-cmd-read"></span><h3>read FILENAME<a class="headerlink" href="#read-filename" title="Link to this heading"></a></h3>
<p><em>Processes SQL and commands in FILENAME (or Python if FILENAME ends with .py)</em></p>
<p>Treats the specified file as input (a mixture or SQL and/or dot commands).  If
the filename ends in .py then it is treated as Python code instead.</p>
<p>For Python code the symbol <code class="docutils literal notranslate"><span class="pre">db</span></code> refers to the current database, <code class="docutils literal notranslate"><span class="pre">shell</span></code>
refers to the instance of the shell and <code class="docutils literal notranslate"><span class="pre">apsw</span></code> is the apsw module.</p>
</section>
<section id="restore-db-file">
<span id="index-32"></span><span id="shell-cmd-restore"></span><h3>restore ?DB? FILE<a class="headerlink" href="#restore-db-file" title="Link to this heading"></a></h3>
<p><em>Restore database from FILE into DB (default “main”)</em></p>
<p>Copies the contents of <code class="docutils literal notranslate"><span class="pre">FILE</span></code> to the current database (default “main”). The
backup is done at the page level - SQLite copies the pages as is.  There is no
round trip through SQL code.</p>
</section>
<section id="schema-table-table">
<span id="index-33"></span><span id="shell-cmd-schema"></span><h3>schema ?TABLE? [TABLE…]<a class="headerlink" href="#schema-table-table" title="Link to this heading"></a></h3>
<p><em>Shows SQL for table</em></p>
<p>If you give one or more tables then their schema is listed (including indices).
If you don’t specify any then all schemas are listed. <code class="docutils literal notranslate"><span class="pre">TABLE</span></code> is a like
pattern so you can use <code class="docutils literal notranslate"><span class="pre">%</span></code> for wildcards.</p>
</section>
<section id="separator-string">
<span id="index-34"></span><span id="shell-cmd-separator"></span><h3>separator STRING<a class="headerlink" href="#separator-string" title="Link to this heading"></a></h3>
<p><em>Change separator for output mode and .import</em></p>
<p>You can use quotes and backslashes.  For example to set the separator to space
tab space you can use:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="o">.</span><span class="n">separator</span> <span class="s2">&quot; </span><span class="se">\\</span><span class="s2">t &quot;</span>
</pre></div>
</div>
<p>The setting is automatically changed when you switch to csv or tabs output mode.
You should also set it before doing an import (ie , for CSV and \t for TSV).</p>
</section>
<section id="shell-cmd-args">
<span id="index-35"></span><span id="shell-cmd-shell"></span><h3>shell CMD ARGS…<a class="headerlink" href="#shell-cmd-args" title="Link to this heading"></a></h3>
<p><em>Run CMD ARGS in a system shell</em></p>
<p>Note that output goes to the process standard output, not whatever the shell
.output command has configured.</p>
</section>
<section id="show">
<span id="index-36"></span><span id="shell-cmd-show"></span><h3>show<a class="headerlink" href="#show" title="Link to this heading"></a></h3>
<p><em>Show the current values for various settings.</em></p>
</section>
<section id="tables-pattern">
<span id="index-37"></span><span id="shell-cmd-tables"></span><h3>tables ?PATTERN?<a class="headerlink" href="#tables-pattern" title="Link to this heading"></a></h3>
<p><em>Lists names of tables matching LIKE pattern</em></p>
<p>This also returns views.</p>
</section>
<section id="timeout-ms">
<span id="index-38"></span><span id="shell-cmd-timeout"></span><h3>timeout MS<a class="headerlink" href="#timeout-ms" title="Link to this heading"></a></h3>
<p><em>Try opening locked tables for MS milliseconds</em></p>
<p>If a database is locked by another process SQLite will keep retrying.  This sets
how many thousandths of a second it will keep trying for.  If you supply zero or
a negative number then all busy handlers are disabled.</p>
</section>
<section id="timer-on-off">
<span id="index-39"></span><span id="shell-cmd-timer"></span><h3>timer ON|OFF<a class="headerlink" href="#timer-on-off" title="Link to this heading"></a></h3>
<p><em>Control printing of time and resource usage after each query</em></p>
<p>The values displayed are in seconds when shown as floating point or an absolute
count.  Only items that have changed since starting the query are shown.  On
non-Windows platforms considerably more information can be shown.</p>
</section>
<section id="version">
<span id="index-40"></span><span id="shell-cmd-version"></span><h3>version<a class="headerlink" href="#version" title="Link to this heading"></a></h3>
<p><em>Displays SQLite, APSW, and Python version information</em></p>
</section>
<section id="vfsinfo">
<span id="index-41"></span><span id="shell-cmd-vfsinfo"></span><h3>vfsinfo<a class="headerlink" href="#vfsinfo" title="Link to this heading"></a></h3>
<p><em>Shows detailed information about the VFS for the database</em></p>
</section>
<section id="vfslist">
<span id="index-42"></span><span id="shell-cmd-vfslist"></span><h3>vfslist<a class="headerlink" href="#vfslist" title="Link to this heading"></a></h3>
<p><em>Shows detailed information about all the VFS available</em></p>
</section>
<section id="vfsname">
<span id="index-43"></span><span id="shell-cmd-vfsname"></span><h3>vfsname<a class="headerlink" href="#vfsname" title="Link to this heading"></a></h3>
<p><em>VFS name for database, or attached names</em></p>
</section>
<section id="width-num-num">
<span id="index-44"></span><span id="shell-cmd-width"></span><h3>width NUM NUM …<a class="headerlink" href="#width-num-num" title="Link to this heading"></a></h3>
<p><em>Set the column widths for “column” mode</em></p>
<p>In “column” output mode, each column is a fixed width with values truncated to
fit.  Specify new widths using this command.  Use a negative number to right
justify and zero for default column width.</p>
</section>
</section>
<section id="shell-class">
<h2>Shell class<a class="headerlink" href="#shell-class" title="Link to this heading"></a></h2>
<p>This is the API should you want extend the shell with your own commands
and output modes. Not shown here are the functions that implement various
commands.  They are named after the command.  For example .exit is
implemented by command_exit.  You can add new commands by having your
subclass have the relevant functions.  The doc string of the function is
used by the help command.  Output modes work in a similar way.  For example
there is an output_html method and again doc strings are used by the help
function and you add more by just implementing an appropriately named
method.</p>
<p>Note that in addition to extending the shell, you can also use the
<strong>.read</strong> command supplying a filename with a <strong>.py</strong> extension.  You
can then <a class="reference external" href="https://en.wikipedia.org/wiki/Monkey_patch">monkey patch</a>
the shell as needed.</p>
<dl class="py class" id="module-apsw.shell">
<dt class="sig sig-object py" id="apsw.shell.Shell">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">apsw.shell.</span></span><span class="sig-name descname"><span class="pre">Shell</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">stdin</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.TextIO" title="(in Python v3.12)"><span class="pre">TextIO</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.12)"><span class="pre">None</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stdout</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.TextIO" title="(in Python v3.12)"><span class="pre">TextIO</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.12)"><span class="pre">None</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">stderr</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/typing.html#typing.TextIO" title="(in Python v3.12)"><span class="pre">TextIO</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.12)"><span class="pre">None</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">encoding</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.12)"><span class="pre">str</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">'utf8'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">args</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.12)"><span class="pre">list</span></a><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.12)"><span class="pre">str</span></a><span class="p"><span class="pre">]</span></span><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.12)"><span class="pre">None</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">db</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="connection.html#apsw.Connection" title="apsw.Connection"><span class="pre">Connection</span></a><span class="w"> </span><span class="p"><span class="pre">|</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.12)"><span class="pre">None</span></a></span><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell" title="Link to this definition"></a></dt>
<dd><p>Implements a SQLite shell</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>stdin</strong> – Where to read input from (default sys.stdin)</p></li>
<li><p><strong>stdout</strong> – Where to send output (default sys.stdout)</p></li>
<li><p><strong>stderr</strong> – Where to send errors (default sys.stderr)</p></li>
<li><p><strong>encoding</strong> – Default encoding for files opened/created by the
Shell.  If you want stdin/out/err to use a particular encoding
then you need to provide them <a class="reference external" href="https://docs.python.org/3/library/codecs.html#codecs.open">already configured</a> that way.</p></li>
<li><p><strong>args</strong> – This should be program arguments only (ie if
passing in sys.argv do not include sys.argv[0] which is the
program name.  You can also pass in None and then call
<a class="reference internal" href="#apsw.shell.Shell.process_args" title="apsw.shell.Shell.process_args"><code class="xref py py-meth docutils literal notranslate"><span class="pre">process_args()</span></code></a> if you want to catch any errors
in handling the arguments yourself.</p></li>
<li><p><strong>db</strong> – A existing <a class="reference internal" href="connection.html#apsw.Connection" title="apsw.Connection"><code class="xref py py-class docutils literal notranslate"><span class="pre">Connection</span></code></a> you wish to use</p></li>
</ul>
</dd>
</dl>
<p>Errors and diagnostics are only ever sent to error output
(self.stderr) and never to the regular output (self.stdout).</p>
<p>Shell commands begin with a dot (eg .help).  They are implemented
as a method named after the command (eg command_help).  The method
is passed one parameter which is the list of arguments to the
command.</p>
<p>Output modes are implemented by functions named after the mode (eg
output_column for columns).</p>
<p>When you request help the help information is automatically
generated from the docstrings for the command and output
functions.</p>
<p>You should not use a Shell object concurrently from multiple
threads.  It is one huge set of state information which would
become inconsistent if used simultaneously.</p>
<dl class="py exception">
<dt class="sig sig-object py" id="apsw.shell.Shell.Error">
<em class="property"><span class="pre">exception</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">Error</span></span><a class="reference internal" href="_modules/apsw/shell.html#Shell.Error"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.Error" title="Link to this definition"></a></dt>
<dd><p>Class raised on errors.  The expectation is that the error
will be displayed by the shell as text so there are no
specific subclasses as the distinctions between different
types of errors doesn’t matter.</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="apsw.shell.Shell.PositionRow">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">PositionRow</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">source</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.PositionRow"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.PositionRow" title="Link to this definition"></a></dt>
<dd><p>Wraps an iterator so you know if a row is first, last, both, or neither</p>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="apsw.shell.Shell.Row">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">Row</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">is_first</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.12)"><span class="pre">bool</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">is_last</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.12)"><span class="pre">bool</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">row</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="apsw.html#apsw.SQLiteValues" title="apsw.SQLiteValues"><span class="pre">apsw.SQLiteValues</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">columns</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.12)"><span class="pre">tuple</span></a><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.12)"><span class="pre">str</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="p"><span class="pre">...</span></span><span class="p"><span class="pre">]</span></span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.Row"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.Row" title="Link to this definition"></a></dt>
<dd><p>Returned by <a class="reference internal" href="#apsw.shell.Shell.PositionRow" title="apsw.shell.Shell.PositionRow"><code class="xref py py-class docutils literal notranslate"><span class="pre">Shell.PositionRow</span></code></a></p>
<dl class="py attribute">
<dt class="sig sig-object py" id="apsw.shell.Shell.Row.columns">
<span class="sig-name descname"><span class="pre">columns</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.12)"><span class="pre">tuple</span></a><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.12)"><span class="pre">str</span></a><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="p"><span class="pre">...</span></span><span class="p"><span class="pre">]</span></span></em><a class="headerlink" href="#apsw.shell.Shell.Row.columns" title="Link to this definition"></a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="apsw.shell.Shell.Row.is_first">
<span class="sig-name descname"><span class="pre">is_first</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.12)"><span class="pre">bool</span></a></em><a class="headerlink" href="#apsw.shell.Shell.Row.is_first" title="Link to this definition"></a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="apsw.shell.Shell.Row.is_last">
<span class="sig-name descname"><span class="pre">is_last</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/functions.html#bool" title="(in Python v3.12)"><span class="pre">bool</span></a></em><a class="headerlink" href="#apsw.shell.Shell.Row.is_last" title="Link to this definition"></a></dt>
<dd></dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="apsw.shell.Shell.Row.row">
<span class="sig-name descname"><span class="pre">row</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><a class="reference internal" href="apsw.html#apsw.SQLiteValues" title="apsw.SQLiteValues"><span class="pre">apsw.SQLiteValues</span></a></em><a class="headerlink" href="#apsw.shell.Shell.Row.row" title="Link to this definition"></a></dt>
<dd></dd></dl>

</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.cmdloop">
<span class="sig-name descname"><span class="pre">cmdloop</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">intro</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">transient</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.cmdloop"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.cmdloop" title="Link to this definition"></a></dt>
<dd><p>Runs the main interactive command loop.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>intro</strong> – Initial text banner to display instead of the
default.  Make sure you newline terminate it.</p></li>
<li><p><strong>transient</strong> – Additional message about being connected to
a transient in memory database</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.complete">
<span class="sig-name descname"><span class="pre">complete</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">token</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">state</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.complete"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.complete" title="Link to this definition"></a></dt>
<dd><p>Return a possible completion for <a class="reference external" href="https://docs.python.org/3/library/readline.html#module-readline" title="(in Python v3.12)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">readline</span></code></a></p>
<p>This function is called with state starting at zero to get the
first completion, then one/two/three etc until you return None.  The best
implementation is to generate the list when state==0, save it,
and provide members on each increase.</p>
<p>The default implementation extracts the current full input
from readline and then calls <a class="reference internal" href="#apsw.shell.Shell.complete_command" title="apsw.shell.Shell.complete_command"><code class="xref py py-meth docutils literal notranslate"><span class="pre">complete_command()</span></code></a> or
<a class="reference internal" href="#apsw.shell.Shell.complete_sql" title="apsw.shell.Shell.complete_sql"><code class="xref py py-meth docutils literal notranslate"><span class="pre">complete_sql()</span></code></a> as appropriate saving the results for
subsequent calls.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.complete_command">
<span class="sig-name descname"><span class="pre">complete_command</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">line</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">token</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">beg</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">end</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.complete_command"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.complete_command" title="Link to this definition"></a></dt>
<dd><p>Provide some completions for dot commands</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>line</strong> – The current complete input line</p></li>
<li><p><strong>token</strong> – The word readline is looking for matches</p></li>
<li><p><strong>beg</strong> – Integer offset of token in line</p></li>
<li><p><strong>end</strong> – Integer end of token in line</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A list of completions, or an empty list if none</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.complete_sql">
<span class="sig-name descname"><span class="pre">complete_sql</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">line</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">token</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">beg</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">end</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.complete_sql"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.complete_sql" title="Link to this definition"></a></dt>
<dd><p>Provide some completions for SQL</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>line</strong> – The current complete input line</p></li>
<li><p><strong>token</strong> – The word readline is looking for matches</p></li>
<li><p><strong>beg</strong> – Integer offset of token in line</p></li>
<li><p><strong>end</strong> – Integer end of token in line</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A list of completions, or an empty list if none</p>
</dd>
</dl>
</dd></dl>

<dl class="py property">
<dt class="sig sig-object py" id="apsw.shell.Shell.db">
<em class="property"><span class="pre">property</span><span class="w"> </span></em><span class="sig-name descname"><span class="pre">db</span></span><a class="headerlink" href="#apsw.shell.Shell.db" title="Link to this definition"></a></dt>
<dd><p>The current <a class="reference internal" href="connection.html#apsw.Connection" title="apsw.Connection"><code class="xref py py-class docutils literal notranslate"><span class="pre">Connection</span></code></a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.display_timing">
<span class="sig-name descname"><span class="pre">display_timing</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">before</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">after</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.display_timing"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.display_timing" title="Link to this definition"></a></dt>
<dd><p>Writes the difference between before and after to self.stderr.
The data is dictionaries returned from
<a class="reference internal" href="#apsw.shell.Shell.get_resource_usage" title="apsw.shell.Shell.get_resource_usage"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get_resource_usage()</span></code></a>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.fixup_backslashes">
<span class="sig-name descname"><span class="pre">fixup_backslashes</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">s</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.fixup_backslashes"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.fixup_backslashes" title="Link to this definition"></a></dt>
<dd><p>Implements the various backlash sequences in s such as
turning backslash t into a tab.</p>
<p>This function is needed because <a class="reference external" href="https://docs.python.org/3/library/shlex.html#module-shlex" title="(in Python v3.12)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">shlex</span></code></a> does not do it for us.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.get_complete_line">
<span class="sig-name descname"><span class="pre">get_complete_line</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.get_complete_line"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.get_complete_line" title="Link to this definition"></a></dt>
<dd><p>Returns a complete input.</p>
<p>For dot commands it will be one line.  For SQL statements it
will be as many as is necessary to have a
<a class="reference internal" href="apsw.html#apsw.complete" title="apsw.complete"><code class="xref py py-meth docutils literal notranslate"><span class="pre">complete()</span></code></a> statement (ie semicolon terminated).
Returns None on end of file.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.get_line">
<span class="sig-name descname"><span class="pre">get_line</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">prompt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">''</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.get_line"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.get_line" title="Link to this definition"></a></dt>
<dd><p>Returns a single line of input (may be incomplete SQL) from self.stdin.</p>
<p>If EOF is reached then return None.  Do not include trailing
newline in return.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.get_resource_usage">
<span class="sig-name descname"><span class="pre">get_resource_usage</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.get_resource_usage"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.get_resource_usage" title="Link to this definition"></a></dt>
<dd><p>Return a dict of various numbers (ints or floats).  The
.timer command shows the difference between before and after
results of what this returns by calling <a class="reference internal" href="#apsw.shell.Shell.display_timing" title="apsw.shell.Shell.display_timing"><code class="xref py py-meth docutils literal notranslate"><span class="pre">display_timing()</span></code></a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.handle_exception">
<span class="sig-name descname"><span class="pre">handle_exception</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.handle_exception"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.handle_exception" title="Link to this definition"></a></dt>
<dd><p>Handles the current exception, printing a message to stderr as appropriate.
It will reraise the exception if necessary (eg if bail is true)</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.handle_interrupt">
<span class="sig-name descname"><span class="pre">handle_interrupt</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.handle_interrupt"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.handle_interrupt" title="Link to this definition"></a></dt>
<dd><p>Deal with keyboard interrupt (typically Control-C).  It
will <a class="reference internal" href="connection.html#apsw.Connection.interrupt" title="apsw.Connection.interrupt"><code class="xref py py-meth docutils literal notranslate"><span class="pre">interrupt()</span></code></a> the database and print”^C” if interactive.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.log_handler">
<span class="sig-name descname"><span class="pre">log_handler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">code</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">message</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.log_handler"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.log_handler" title="Link to this definition"></a></dt>
<dd><p>Called with SQLite log messages when logging is ON</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.pop_input">
<span class="sig-name descname"><span class="pre">pop_input</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.pop_input"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.pop_input" title="Link to this definition"></a></dt>
<dd><p>Restore most recently pushed input parameters (interactive,
self.stdin, linenumber etc).  Use this if implementing a
command like read.  Push the current input, read the file and
then pop the input to go back to before.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.pop_output">
<span class="sig-name descname"><span class="pre">pop_output</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.pop_output"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.pop_output" title="Link to this definition"></a></dt>
<dd><p>Restores most recently pushed output.  There are many
output parameters such as nullvalue, mode
(list/tcl/html/insert etc), column widths, header etc.  If you
temporarily need to change some settings then
<a class="reference internal" href="#apsw.shell.Shell.push_output" title="apsw.shell.Shell.push_output"><code class="xref py py-meth docutils literal notranslate"><span class="pre">push_output()</span></code></a>, change the settings and then pop the old
ones back.</p>
<p>A simple example is implementing a command like .dump.  Push
the current output, change the mode to insert so we get SQL
inserts printed and then pop to go back to what was there
before.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.process_args">
<span class="sig-name descname"><span class="pre">process_args</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.process_args"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.process_args" title="Link to this definition"></a></dt>
<dd><p>Process command line options specified in args.  It is safe to
call this multiple times.  We try to be compatible with SQLite shell
argument parsing.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>args</strong> – A list of string options.  Do not include the
program as args[0]</p>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A tuple of (databasefilename, initfiles,
sqlncommands).  This is provided for informational purposes
only - they have already been acted upon.  An example use
is that the SQLite shell does not enter the main interactive
loop if any sql/commands were provided.</p>
</dd>
</dl>
<p>The first non-option is the database file name.  Each
remaining non-option is treated as a complete input (ie it
isn’t joined with others looking for a trailing semi-colon).</p>
<p>The SQLite shell uses single dash in front of options.  We
allow both single and double dashes.  When an unrecognized
argument is encountered then
<a class="reference internal" href="#apsw.shell.Shell.process_unknown_args" title="apsw.shell.Shell.process_unknown_args"><code class="xref py py-meth docutils literal notranslate"><span class="pre">process_unknown_args()</span></code></a> is called.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.process_command">
<span class="sig-name descname"><span class="pre">process_command</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">command</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.process_command"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.process_command" title="Link to this definition"></a></dt>
<dd><p>Processes a dot command.</p>
<p>It is split into parts using <a class="reference external" href="https://docs.python.org/3/library/shlex.html#shlex.split" title="(in Python v3.12)"><code class="xref py py-func docutils literal notranslate"><span class="pre">shlex.split()</span></code></a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.process_complete_line">
<span class="sig-name descname"><span class="pre">process_complete_line</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">command</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.process_complete_line"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.process_complete_line" title="Link to this definition"></a></dt>
<dd><p>Given some text will call the appropriate method to process
it (eg <a class="reference internal" href="#apsw.shell.Shell.process_sql" title="apsw.shell.Shell.process_sql"><code class="xref py py-meth docutils literal notranslate"><span class="pre">process_sql()</span></code></a> or <a class="reference internal" href="#apsw.shell.Shell.process_command" title="apsw.shell.Shell.process_command"><code class="xref py py-meth docutils literal notranslate"><span class="pre">process_command()</span></code></a>)</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.process_sql">
<span class="sig-name descname"><span class="pre">process_sql</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">sql</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.12)"><span class="pre">str</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">bindings</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">internal</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">summary</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.process_sql"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.process_sql" title="Link to this definition"></a></dt>
<dd><p>Processes SQL text consisting of one or more statements</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>sql</strong> – SQL to execute</p></li>
<li><p><strong>bindings</strong> – bindings for the <em>sql</em></p></li>
<li><p><strong>internal</strong> – If True then this is an internal execution
(eg the .tables or .database command).  When executing
internal sql timings are not shown nor is the SQL echoed.</p></li>
<li><p><strong>summary</strong> – If not None then should be a tuple of two
items.  If the <code class="docutils literal notranslate"><span class="pre">sql</span></code> returns any data then the first item
is printed before the first row, and the second item is
printed after the last row.  An example usage is the .find
command which shows table names.</p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.process_unknown_args">
<span class="sig-name descname"><span class="pre">process_unknown_args</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">args</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.process_unknown_args"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.process_unknown_args" title="Link to this definition"></a></dt>
<dd><p>This is called when <a class="reference internal" href="#apsw.shell.Shell.process_args" title="apsw.shell.Shell.process_args"><code class="xref py py-meth docutils literal notranslate"><span class="pre">process_args()</span></code></a> encounters an
argument it doesn’t understand.  Override this method if you
want to be able to understand additional command line arguments.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>args</strong> – A list of the remaining arguments.  The initial one will
have had the leading dashes removed (eg if it was –foo on the command
line then args[0] will be “foo”</p>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>None if you don’t recognize the argument either.  Otherwise
return the list of remaining arguments after you have processed
yours.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.push_input">
<span class="sig-name descname"><span class="pre">push_input</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.push_input"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.push_input" title="Link to this definition"></a></dt>
<dd><p>Saves the current input parameters to a stack.  See <a class="reference internal" href="#apsw.shell.Shell.pop_input" title="apsw.shell.Shell.pop_input"><code class="xref py py-meth docutils literal notranslate"><span class="pre">pop_input()</span></code></a>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.push_output">
<span class="sig-name descname"><span class="pre">push_output</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.push_output"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.push_output" title="Link to this definition"></a></dt>
<dd><p>Saves the current output settings onto a stack.  See
<a class="reference internal" href="#apsw.shell.Shell.pop_output" title="apsw.shell.Shell.pop_output"><code class="xref py py-meth docutils literal notranslate"><span class="pre">pop_output()</span></code></a> for more details as to why you would use
this.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.set_encoding">
<span class="sig-name descname"><span class="pre">set_encoding</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">enc</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.set_encoding"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.set_encoding" title="Link to this definition"></a></dt>
<dd><p>Saves <em>enc</em> as the default encoding, after verifying that
it is valid.  You can also include :error to specify error
handling - eg ‘cp437:replace’</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.usage">
<span class="sig-name descname"><span class="pre">usage</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.usage"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.usage" title="Link to this definition"></a></dt>
<dd><p>Returns the usage message.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.write">
<span class="sig-name descname"><span class="pre">write</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dest</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">text</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.write"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.write" title="Link to this definition"></a></dt>
<dd><p>Writes text to dest.  dest will typically be one of self.stdout or self.stderr.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.write_error">
<span class="sig-name descname"><span class="pre">write_error</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">text</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.write_error"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.write_error" title="Link to this definition"></a></dt>
<dd><p>Writes text to self.stderr colouring it</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.shell.Shell.write_value">
<span class="sig-name descname"><span class="pre">write_value</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">value</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">fmt</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">apsw.format_sql_value</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/apsw/shell.html#Shell.write_value"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.Shell.write_value" title="Link to this definition"></a></dt>
<dd><p>Writes colourized value to self.stdout converting to text with fmt</p>
</dd></dl>

</dd></dl>

<dl class="py function">
<dt class="sig sig-object py" id="apsw.shell.main">
<span class="sig-prename descclassname"><span class="pre">apsw.shell.</span></span><span class="sig-name descname"><span class="pre">main</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference external" href="https://docs.python.org/3/library/constants.html#None" title="(in Python v3.12)"><span class="pre">None</span></a></span></span><a class="reference internal" href="_modules/apsw/shell.html#main"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#apsw.shell.main" title="Link to this definition"></a></dt>
<dd><p>Call this to run the <a class="reference internal" href="#shell"><span class="std std-ref">interactive shell</span></a>.  It
automatically passes in sys.argv[1:] and exits Python when done.</p>
</dd></dl>

</section>
</section>


           </div>
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="vfs.html" class="btn btn-neutral float-left" title="Virtual File System (VFS)" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="bestpractice.html" class="btn btn-neutral float-right" title="Best Practice" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; <a href="copyright.html">Copyright</a> 2004-2024, Roger Binns &lt;rogerb@rogerbinns.com&gt;.
      <span class="lastupdated">Last updated on Jun 16, 2024.
      </span></p>
  </div>

  Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
    <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
    provided by <a href="https://readthedocs.org">Read the Docs</a>.
   

</footer>
        </div>
      </div>
    </section>
  </div>
  <script>
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>