File: connection.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 (1560 lines) | stat: -rw-r--r-- 213,536 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
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
<!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>Connections to a database &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="Cursors (executing SQL)" href="cursor.html" />
    <link rel="prev" title="APSW Module" href="apsw.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 current"><a class="current reference internal" href="#">Connections to a database</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#connection-class">Connection class</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#apsw.Connection"><code class="docutils literal notranslate"><span class="pre">Connection</span></code></a><ul>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.__enter__"><code class="docutils literal notranslate"><span class="pre">Connection.__enter__()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.__exit__"><code class="docutils literal notranslate"><span class="pre">Connection.__exit__()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.authorizer"><code class="docutils literal notranslate"><span class="pre">Connection.authorizer</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.autovacuum_pages"><code class="docutils literal notranslate"><span class="pre">Connection.autovacuum_pages()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.backup"><code class="docutils literal notranslate"><span class="pre">Connection.backup()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.blob_open"><code class="docutils literal notranslate"><span class="pre">Connection.blob_open()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.cache_flush"><code class="docutils literal notranslate"><span class="pre">Connection.cache_flush()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.cache_stats"><code class="docutils literal notranslate"><span class="pre">Connection.cache_stats()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.changes"><code class="docutils literal notranslate"><span class="pre">Connection.changes()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.close"><code class="docutils literal notranslate"><span class="pre">Connection.close()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.collation_needed"><code class="docutils literal notranslate"><span class="pre">Connection.collation_needed()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.column_metadata"><code class="docutils literal notranslate"><span class="pre">Connection.column_metadata()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.config"><code class="docutils literal notranslate"><span class="pre">Connection.config()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.create_aggregate_function"><code class="docutils literal notranslate"><span class="pre">Connection.create_aggregate_function()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.create_collation"><code class="docutils literal notranslate"><span class="pre">Connection.create_collation()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.create_module"><code class="docutils literal notranslate"><span class="pre">Connection.create_module()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.create_scalar_function"><code class="docutils literal notranslate"><span class="pre">Connection.create_scalar_function()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.create_window_function"><code class="docutils literal notranslate"><span class="pre">Connection.create_window_function()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.cursor"><code class="docutils literal notranslate"><span class="pre">Connection.cursor()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.cursor_factory"><code class="docutils literal notranslate"><span class="pre">Connection.cursor_factory</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.db_filename"><code class="docutils literal notranslate"><span class="pre">Connection.db_filename()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.db_names"><code class="docutils literal notranslate"><span class="pre">Connection.db_names()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.deserialize"><code class="docutils literal notranslate"><span class="pre">Connection.deserialize()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.drop_modules"><code class="docutils literal notranslate"><span class="pre">Connection.drop_modules()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.enable_load_extension"><code class="docutils literal notranslate"><span class="pre">Connection.enable_load_extension()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.exec_trace"><code class="docutils literal notranslate"><span class="pre">Connection.exec_trace</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.execute"><code class="docutils literal notranslate"><span class="pre">Connection.execute()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.executemany"><code class="docutils literal notranslate"><span class="pre">Connection.executemany()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.file_control"><code class="docutils literal notranslate"><span class="pre">Connection.file_control()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.filename"><code class="docutils literal notranslate"><span class="pre">Connection.filename</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.filename_journal"><code class="docutils literal notranslate"><span class="pre">Connection.filename_journal</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.filename_wal"><code class="docutils literal notranslate"><span class="pre">Connection.filename_wal</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.get_autocommit"><code class="docutils literal notranslate"><span class="pre">Connection.get_autocommit()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.get_exec_trace"><code class="docutils literal notranslate"><span class="pre">Connection.get_exec_trace()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.get_row_trace"><code class="docutils literal notranslate"><span class="pre">Connection.get_row_trace()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.in_transaction"><code class="docutils literal notranslate"><span class="pre">Connection.in_transaction</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.interrupt"><code class="docutils literal notranslate"><span class="pre">Connection.interrupt()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.is_interrupted"><code class="docutils literal notranslate"><span class="pre">Connection.is_interrupted</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.last_insert_rowid"><code class="docutils literal notranslate"><span class="pre">Connection.last_insert_rowid()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.limit"><code class="docutils literal notranslate"><span class="pre">Connection.limit()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.load_extension"><code class="docutils literal notranslate"><span class="pre">Connection.load_extension()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.open_flags"><code class="docutils literal notranslate"><span class="pre">Connection.open_flags</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.open_vfs"><code class="docutils literal notranslate"><span class="pre">Connection.open_vfs</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.overload_function"><code class="docutils literal notranslate"><span class="pre">Connection.overload_function()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.pragma"><code class="docutils literal notranslate"><span class="pre">Connection.pragma()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.read"><code class="docutils literal notranslate"><span class="pre">Connection.read()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.readonly"><code class="docutils literal notranslate"><span class="pre">Connection.readonly()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.release_memory"><code class="docutils literal notranslate"><span class="pre">Connection.release_memory()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.row_trace"><code class="docutils literal notranslate"><span class="pre">Connection.row_trace</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.serialize"><code class="docutils literal notranslate"><span class="pre">Connection.serialize()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.set_authorizer"><code class="docutils literal notranslate"><span class="pre">Connection.set_authorizer()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.set_busy_handler"><code class="docutils literal notranslate"><span class="pre">Connection.set_busy_handler()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.set_busy_timeout"><code class="docutils literal notranslate"><span class="pre">Connection.set_busy_timeout()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.set_commit_hook"><code class="docutils literal notranslate"><span class="pre">Connection.set_commit_hook()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.set_exec_trace"><code class="docutils literal notranslate"><span class="pre">Connection.set_exec_trace()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.set_last_insert_rowid"><code class="docutils literal notranslate"><span class="pre">Connection.set_last_insert_rowid()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.set_profile"><code class="docutils literal notranslate"><span class="pre">Connection.set_profile()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.set_progress_handler"><code class="docutils literal notranslate"><span class="pre">Connection.set_progress_handler()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.set_rollback_hook"><code class="docutils literal notranslate"><span class="pre">Connection.set_rollback_hook()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.set_row_trace"><code class="docutils literal notranslate"><span class="pre">Connection.set_row_trace()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.set_update_hook"><code class="docutils literal notranslate"><span class="pre">Connection.set_update_hook()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.set_wal_hook"><code class="docutils literal notranslate"><span class="pre">Connection.set_wal_hook()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.sqlite3_pointer"><code class="docutils literal notranslate"><span class="pre">Connection.sqlite3_pointer()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.status"><code class="docutils literal notranslate"><span class="pre">Connection.status()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.system_errno"><code class="docutils literal notranslate"><span class="pre">Connection.system_errno</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.table_exists"><code class="docutils literal notranslate"><span class="pre">Connection.table_exists()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.total_changes"><code class="docutils literal notranslate"><span class="pre">Connection.total_changes()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.trace_v2"><code class="docutils literal notranslate"><span class="pre">Connection.trace_v2()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.txn_state"><code class="docutils literal notranslate"><span class="pre">Connection.txn_state()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.vfsname"><code class="docutils literal notranslate"><span class="pre">Connection.vfsname()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.vtab_config"><code class="docutils literal notranslate"><span class="pre">Connection.vtab_config()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.vtab_on_conflict"><code class="docutils literal notranslate"><span class="pre">Connection.vtab_on_conflict()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.wal_autocheckpoint"><code class="docutils literal notranslate"><span class="pre">Connection.wal_autocheckpoint()</span></code></a></li>
<li class="toctree-l4"><a class="reference internal" href="#apsw.Connection.wal_checkpoint"><code class="docutils literal notranslate"><span class="pre">Connection.wal_checkpoint()</span></code></a></li>
</ul>
</li>
</ul>
</li>
</ul>
</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"><a class="reference internal" href="shell.html">Shell</a></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">Connections to a database</li>
      <li class="wy-breadcrumbs-aside">
            <a href="_sources/connection.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul><div class="rst-breadcrumbs-buttons" role="navigation" aria-label="Sequential page navigation">
        <a href="apsw.html" class="btn btn-neutral float-left" title="APSW Module" accesskey="p"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="cursor.html" class="btn btn-neutral float-right" title="Cursors (executing SQL)" 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="connections-to-a-database">
<span id="connections"></span><h1>Connections to a database<a class="headerlink" href="#connections-to-a-database" title="Link to this heading"></a></h1>
<p>A <a class="reference internal" href="#apsw.Connection" title="apsw.Connection"><code class="xref py py-class docutils literal notranslate"><span class="pre">Connection</span></code></a> encapsulates access to a database.  You can have
multiple <a class="reference internal" href="#apsw.Connection" title="apsw.Connection"><code class="xref py py-class docutils literal notranslate"><span class="pre">Connections</span></code></a> open against the same
database file in the same process, across threads and in other
processes.</p>
<section id="connection-class">
<h2>Connection class<a class="headerlink" href="#connection-class" title="Link to this heading"></a></h2>
<dl class="py class" id="index-0">
<dt class="sig sig-object py" id="apsw.Connection">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">apsw.</span></span><span class="sig-name descname"><span class="pre">Connection</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</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">flags</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#int" title="(in Python v3.12)"><span class="pre">int</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">SQLITE_OPEN_READWRITE</span> <span class="pre">|</span> <span class="pre">SQLITE_OPEN_CREATE</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">vfs</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 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">statementcachesize</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#int" title="(in Python v3.12)"><span class="pre">int</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">100</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#apsw.Connection" title="Link to this definition"></a></dt>
<dd><p>This object wraps a <a class="reference external" href="https://sqlite.org/c3ref/sqlite3.html">sqlite3 pointer</a>.</p>
<p>Opens the named database.  You can use <code class="docutils literal notranslate"><span class="pre">:memory:</span></code> to get a private temporary
in-memory database that is not shared with any other connections.</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>flags</strong> – One or more of the <a class="reference external" href="https://sqlite.org/c3ref/c_open_autoproxy.html">open flags</a> orred together</p></li>
<li><p><strong>vfs</strong> – The name of the <a class="reference external" href="https://sqlite.org/c3ref/vfs.html">vfs</a> to use.  If <em>None</em> then the default
vfs will be used.</p></li>
<li><p><strong>statementcachesize</strong> – Use zero to disable the statement cache,
or a number larger than the total distinct SQL statements you
execute frequently.</p></li>
</ul>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="apsw.html#apsw.connection_hooks" title="apsw.connection_hooks"><code class="xref py py-attr docutils literal notranslate"><span class="pre">apsw.connection_hooks</span></code></a></p></li>
<li><p><a class="reference internal" href="execution.html#statementcache"><span class="std std-ref">Statement Cache</span></a></p></li>
<li><p><a class="reference internal" href="vfs.html#vfs"><span class="std std-ref">Virtual File System (VFS)</span></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/open.html">sqlite3_open_v2</a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.Connection.__enter__">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">__enter__</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 internal" href="#apsw.Connection" title="apsw.Connection"><span class="pre">Connection</span></a></span></span><a class="headerlink" href="#apsw.Connection.__enter__" title="Link to this definition"></a></dt>
<dd><p>You can use the database as a <a class="reference external" href="https://docs.python.org/3/reference/datamodel.html#with-statement-context-managers">context manager</a>
as defined in <span class="target" id="index-1"></span><a class="pep reference external" href="https://peps.python.org/pep-0343/"><strong>PEP 0343</strong></a>.  When you use <em>with</em> a transaction is
started.  If the block finishes with an exception then the
transaction is rolled back, otherwise it is committed.  For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">with</span> <span class="n">connection</span><span class="p">:</span>
    <span class="n">connection</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s2">&quot;....&quot;</span><span class="p">)</span>
    <span class="k">with</span> <span class="n">connection</span><span class="p">:</span>
        <span class="c1"># nested is supported</span>
        <span class="n">call_function</span><span class="p">(</span><span class="n">connection</span><span class="p">)</span>
        <span class="n">connection</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s2">&quot;...&quot;</span><span class="p">)</span>
        <span class="k">with</span> <span class="n">connection</span> <span class="k">as</span> <span class="n">db</span><span class="p">:</span>
            <span class="c1"># You can also use &#39;as&#39;</span>
            <span class="n">call_function2</span><span class="p">(</span><span class="n">db</span><span class="p">)</span>
            <span class="n">db</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s2">&quot;...&quot;</span><span class="p">)</span>
</pre></div>
</div>
<dl class="simple">
<dt>Behind the scenes <a class="reference external" href="https://sqlite.org/lang_savepoint.html">savepoints</a></dt><dd><p>are used to provide nested transactions.</p>
</dd>
</dl>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.Connection.__exit__">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">__exit__</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">etype</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#type" title="(in Python v3.12)"><span class="pre">type</span></a><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/exceptions.html#BaseException" title="(in Python v3.12)"><span class="pre">BaseException</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></em>, <em class="sig-param"><span class="n"><span class="pre">evalue</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/exceptions.html#BaseException" title="(in Python v3.12)"><span class="pre">BaseException</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></em>, <em class="sig-param"><span class="n"><span class="pre">etraceback</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/types.html#types.TracebackType" title="(in Python v3.12)"><span class="pre">types.TracebackType</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></em><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/functions.html#bool" title="(in Python v3.12)"><span class="pre">bool</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><a class="headerlink" href="#apsw.Connection.__exit__" title="Link to this definition"></a></dt>
<dd><p>Implements context manager in conjunction with
<a class="reference internal" href="#apsw.Connection.__enter__" title="apsw.Connection.__enter__"><code class="xref py py-meth docutils literal notranslate"><span class="pre">__enter__()</span></code></a>.  If no exception happened then
the pending transaction is committed, while an exception results in a
rollback.</p>
</dd></dl>

<dl class="py attribute" id="index-2">
<dt class="sig sig-object py" id="apsw.Connection.authorizer">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">authorizer</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.Authorizer" title="apsw.Authorizer"><span class="pre">Authorizer</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></em><a class="headerlink" href="#apsw.Connection.authorizer" title="Link to this definition"></a></dt>
<dd><p>While <a class="reference external" href="https://sqlite.org/c3ref/prepare.html">preparing</a>
statements, SQLite will call any defined authorizer to see if a
particular action is ok to be part of the statement.</p>
<p>Typical usage would be if you are running user supplied SQL and want
to prevent harmful operations.  You should also
set the <a class="reference internal" href="#apsw.Connection" title="apsw.Connection"><code class="xref py py-class docutils literal notranslate"><span class="pre">statementcachesize</span></code></a> to zero.</p>
<p>The authorizer callback has 5 parameters:</p>
<blockquote>
<div><ul class="simple">
<li><p>An <a class="reference external" href="https://sqlite.org/c3ref/c_alter_table.html">operation code</a></p></li>
<li><p>A string (or None) dependent on the operation <a class="reference external" href="https://sqlite.org/c3ref/c_alter_table.html">(listed as 3rd)</a></p></li>
<li><p>A string (or None) dependent on the operation <a class="reference external" href="https://sqlite.org/c3ref/c_alter_table.html">(listed as 4th)</a></p></li>
<li><p>A string name of the database (or None)</p></li>
<li><p>Name of the innermost trigger or view doing the access (or None)</p></li>
</ul>
</div></blockquote>
<p>The authorizer callback should return one of <em>SQLITE_OK</em>,
<em>SQLITE_DENY</em> or <em>SQLITE_IGNORE</em>.
(<em>SQLITE_DENY</em> is returned if there is an error in your
Python code).</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="example.html#example-authorizer"><span class="std std-ref">Example</span></a></p></li>
<li><p><a class="reference internal" href="execution.html#statementcache"><span class="std std-ref">Statement Cache</span></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/set_authorizer.html">sqlite3_set_authorizer</a></p>
</dd></dl>

<dl class="py method" id="index-3">
<dt class="sig sig-object py" id="apsw.Connection.autovacuum_pages">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">autovacuum_pages</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">callable</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><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><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a><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#int" title="(in Python v3.12)"><span class="pre">int</span></a><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#int" title="(in Python v3.12)"><span class="pre">int</span></a><span class="p"><span class="pre">]</span></span><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#int" title="(in Python v3.12)"><span class="pre">int</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></em><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="headerlink" href="#apsw.Connection.autovacuum_pages" title="Link to this definition"></a></dt>
<dd><p>Calls <cite>callable</cite> to find out how many pages to autovacuum.  The callback has 4 parameters:</p>
<ul class="simple">
<li><p>Database name: str. <cite>main</cite>, <cite>temp</cite>, the name in <a class="reference external" href="https://sqlite.org/lang_attach.html">ATTACH</a></p></li>
<li><p>Database pages: int (how many pages make up the database now)</p></li>
<li><p>Free pages: int (how many pages could be freed)</p></li>
<li><p>Page size: int (page size in bytes)</p></li>
</ul>
<p>Return how many pages should be freed.  Values less than zero or more than the free pages are
treated as zero or free page count.  On error zero is returned.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>READ THE NOTE IN THE SQLITE DOCUMENTATION.</p>
<p>Calling back into SQLite can result in crashes, corrupt
databases, or worse.</p>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/autovacuum_pages.html">sqlite3_autovacuum_pages</a></p>
</dd></dl>

<dl class="py method" id="index-4">
<dt class="sig sig-object py" id="apsw.Connection.backup">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">backup</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">databasename</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">sourceconnection</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="#apsw.Connection" title="apsw.Connection"><span class="pre">Connection</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">sourcedatabasename</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><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="backup.html#apsw.Backup" title="apsw.Backup"><span class="pre">Backup</span></a></span></span><a class="headerlink" href="#apsw.Connection.backup" title="Link to this definition"></a></dt>
<dd><p>Opens a <a class="reference internal" href="backup.html#backup"><span class="std std-ref">backup object</span></a>.  All data will be copied from source
database to this database.</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>databasename</strong> – Name of the database. <cite>main</cite>, <cite>temp</cite>, the name in <a class="reference external" href="https://sqlite.org/lang_attach.html">ATTACH</a></p></li>
<li><p><strong>sourceconnection</strong> – The <a class="reference internal" href="#apsw.Connection" title="apsw.Connection"><code class="xref py py-class docutils literal notranslate"><span class="pre">Connection</span></code></a> to copy a database from.</p></li>
<li><p><strong>sourcedatabasename</strong> – Name of the database in the source (eg <code class="docutils literal notranslate"><span class="pre">main</span></code>).</p></li>
</ul>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p><a class="reference internal" href="backup.html#apsw.Backup" title="apsw.Backup"><code class="xref py py-class docutils literal notranslate"><span class="pre">Backup</span></code></a></p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="backup.html"><span class="doc">Backup reference</span></a></p></li>
<li><p><a class="reference internal" href="example.html#example-backup"><span class="std std-ref">Backup example</span></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/backup_finish.html#sqlite3backupinit">sqlite3_backup_init</a></p>
</dd></dl>

<dl class="py method" id="index-5">
<dt class="sig sig-object py" id="apsw.Connection.blob_open">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">blob_open</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">database</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">table</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">column</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">rowid</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#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">writeable</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><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="blob.html#apsw.Blob" title="apsw.Blob"><span class="pre">Blob</span></a></span></span><a class="headerlink" href="#apsw.Connection.blob_open" title="Link to this definition"></a></dt>
<dd><p>Opens a blob for <a class="reference internal" href="blob.html#blobio"><span class="std std-ref">incremental I/O</span></a>.</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>database</strong> – Name of the database.  <cite>main</cite>, <cite>temp</cite>, the name in <a class="reference external" href="https://sqlite.org/lang_attach.html">ATTACH</a>.</p></li>
<li><p><strong>table</strong> – The name of the table</p></li>
<li><p><strong>column</strong> – The name of the column</p></li>
<li><p><strong>rowid</strong> – The id that uniquely identifies the row.</p></li>
<li><p><strong>writeable</strong> – If True then you can read and write the blob.  If False then you can only read it.</p></li>
</ul>
</dd>
<dt class="field-even">Return type<span class="colon">:</span></dt>
<dd class="field-even"><p><a class="reference internal" href="blob.html#apsw.Blob" title="apsw.Blob"><code class="xref py py-class docutils literal notranslate"><span class="pre">Blob</span></code></a></p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="example.html#example-blob-io"><span class="std std-ref">Blob I/O example</span></a></p></li>
<li><p><a class="reference external" href="https://sqlite.org/autoinc.html">SQLite row ids</a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/blob_open.html">sqlite3_blob_open</a></p>
</dd></dl>

<dl class="py method" id="index-6">
<dt class="sig sig-object py" id="apsw.Connection.cache_flush">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">cache_flush</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="headerlink" href="#apsw.Connection.cache_flush" title="Link to this definition"></a></dt>
<dd><p>Flushes caches to disk mid-transaction.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/db_cacheflush.html">sqlite3_db_cacheflush</a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.Connection.cache_stats">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">cache_stats</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">include_entries</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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em><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/stdtypes.html#dict" title="(in Python v3.12)"><span class="pre">dict</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><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#apsw.Connection.cache_stats" title="Link to this definition"></a></dt>
<dd></dd></dl>

<p>Returns information about the statement cache as dict.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Calling execute with “select a; select b; insert into c …” will
result in 3 cache entries corresponding to each of the 3 queries
present.</p>
</div>
<p>The returned dictionary has the following information.</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Explanation</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>size</p></td>
<td><p>Maximum number of entries in the cache</p></td>
</tr>
<tr class="row-odd"><td><p>evictions</p></td>
<td><p>How many entries were removed (expired) to make space for a newer
entry</p></td>
</tr>
<tr class="row-even"><td><p>no_cache</p></td>
<td><p>Queries that had can_cache parameter set to False</p></td>
</tr>
<tr class="row-odd"><td><p>hits</p></td>
<td><p>A match was found in the cache</p></td>
</tr>
<tr class="row-even"><td><p>misses</p></td>
<td><p>No match was found in the cache, or the cache couldn’t be used</p></td>
</tr>
<tr class="row-odd"><td><p>no_vdbe</p></td>
<td><p>The statement was empty (eg a comment) or SQLite took action
during parsing (eg some pragmas).  These are not cached and also
included in the misses count</p></td>
</tr>
<tr class="row-even"><td><p>too_big</p></td>
<td><p>UTF8 query size was larger than considered for caching.  These are also included
in the misses count.</p></td>
</tr>
<tr class="row-odd"><td><p>max_cacheable_bytes</p></td>
<td><p>Maximum size of query (in bytes of utf8) that will be considered for caching</p></td>
</tr>
<tr class="row-even"><td><p>entries</p></td>
<td><p>(Only present if <cite>include_entries</cite> is True) A list of the cache entries</p></td>
</tr>
</tbody>
</table>
<p>If <cite>entries</cite> is present, then each list entry is a dict with the following information.</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Explanation</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>query</p></td>
<td><p>Text of the query itself (first statement only)</p></td>
</tr>
<tr class="row-odd"><td><p>prepare_flags</p></td>
<td><p>Flags passed to <a class="reference external" href="https://sqlite.org/c3ref/prepare.html">sqlite3_prepare_v3</a>
for this query</p></td>
</tr>
<tr class="row-even"><td><p>explain</p></td>
<td><p>The value passed to <a class="reference external" href="https://sqlite.org/c3ref/stmt_explain.html">sqlite3_stmt_explain</a>
if &gt;= 0</p></td>
</tr>
<tr class="row-odd"><td><p>uses</p></td>
<td><p>How many times this entry has been (re)used</p></td>
</tr>
<tr class="row-even"><td><p>has_more</p></td>
<td><p>Boolean indicating if there was more query text than
the first statement</p></td>
</tr>
</tbody>
</table>
<dl class="py method" id="index-7">
<dt class="sig sig-object py" id="apsw.Connection.changes">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">changes</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/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></span><a class="headerlink" href="#apsw.Connection.changes" title="Link to this definition"></a></dt>
<dd><p>Returns the number of database rows that were changed (or inserted
or deleted) by the most recently completed INSERT, UPDATE, or DELETE
statement.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/changes.html">sqlite3_changes64</a></p>
</dd></dl>

<dl class="py method" id="index-8">
<dt class="sig sig-object py" id="apsw.Connection.close">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">close</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">force</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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em><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="headerlink" href="#apsw.Connection.close" title="Link to this definition"></a></dt>
<dd><p>Closes the database.  If there are any outstanding <a class="reference internal" href="cursor.html#apsw.Cursor" title="apsw.Cursor"><code class="xref py py-class docutils literal notranslate"><span class="pre">cursors</span></code></a>, <a class="reference internal" href="blob.html#apsw.Blob" title="apsw.Blob"><code class="xref py py-class docutils literal notranslate"><span class="pre">blobs</span></code></a> or <a class="reference internal" href="backup.html#apsw.Backup" title="apsw.Backup"><code class="xref py py-class docutils literal notranslate"><span class="pre">backups</span></code></a> then
they are closed too.  It is normally not necessary to call this
method as the database is automatically closed when there are no
more references.  It is ok to call the method multiple times.</p>
<p>If your user defined functions or collations have direct or indirect
references to the Connection then it won’t be automatically garbage
collected because of circular referencing that can’t be
automatically broken.  Calling <em>close</em> will free all those objects
and what they reference.</p>
<p>SQLite is designed to survive power failures at even the most
awkward moments.  Consequently it doesn’t matter if it is closed
when the process is exited, or even if the exit is graceful or
abrupt.  In the worst case of having a transaction in progress, that
transaction will be rolled back by the next program to open the
database, reverting the database to a know good state.</p>
<p>If <em>force</em> is <em>True</em> then any exceptions are ignored.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/close.html">sqlite3_close</a></p>
</dd></dl>

<dl class="py method" id="index-9">
<dt class="sig sig-object py" id="apsw.Connection.collation_needed">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">collation_needed</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">callable</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#apsw.Connection" title="apsw.Connection"><span class="pre">Connection</span></a><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#str" title="(in Python v3.12)"><span class="pre">str</span></a><span class="p"><span class="pre">]</span></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 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></em><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="headerlink" href="#apsw.Connection.collation_needed" title="Link to this definition"></a></dt>
<dd><p><em>callable</em> will be called if a statement requires a <a class="reference external" href="https://en.wikipedia.org/wiki/Collation">collation</a> that hasn’t been
registered. Your callable will be passed two parameters. The first
is the connection object. The second is the name of the
collation. If you have the collation code available then call
<a class="reference internal" href="#apsw.Connection.create_collation" title="apsw.Connection.create_collation"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Connection.create_collation()</span></code></a>.</p>
<p>This is useful for creating collations on demand.  For example you
may include the <a class="reference external" href="https://en.wikipedia.org/wiki/Locale">locale</a> in
the collation name, but since there are thousands of locales in
popular use it would not be useful to <a class="reference internal" href="#apsw.Connection.create_collation" title="apsw.Connection.create_collation"><code class="xref py py-meth docutils literal notranslate"><span class="pre">prereigster</span></code></a> them all.  Using
<a class="reference internal" href="#apsw.Connection.collation_needed" title="apsw.Connection.collation_needed"><code class="xref py py-meth docutils literal notranslate"><span class="pre">collation_needed()</span></code></a> tells you when you need to
register them.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="#apsw.Connection.create_collation" title="apsw.Connection.create_collation"><code class="xref py py-meth docutils literal notranslate"><span class="pre">create_collation()</span></code></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/collation_needed.html">sqlite3_collation_needed</a></p>
</dd></dl>

<dl class="py method" id="index-10">
<dt class="sig sig-object py" id="apsw.Connection.column_metadata">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">column_metadata</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dbname</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 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></em>, <em class="sig-param"><span class="n"><span class="pre">table_name</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">column_name</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><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/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><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><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 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><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><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#apsw.Connection.column_metadata" title="Link to this definition"></a></dt>
<dd><p><cite>dbname</cite> is <cite>main</cite>, <cite>temp</cite>, the name in <a class="reference external" href="https://sqlite.org/lang_attach.html">ATTACH</a>, or None to search
all databases.</p>
<p>The returned <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code></a> has these fields:</p>
<p>0: str - declared data type</p>
<p>1: str - name of default collation sequence</p>
<p>2: bool - True if not null constraint</p>
<p>3: bool - True if part of primary key</p>
<p>4: bool - True if column is <a class="reference external" href="https://www.sqlite.org/autoinc.html">autoincrement</a></p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/table_column_metadata.html">sqlite3_table_column_metadata</a></p>
</dd></dl>

<dl class="py method" id="index-11">
<dt class="sig sig-object py" id="apsw.Connection.config">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">config</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">op</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#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span><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/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em><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/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></span><a class="headerlink" href="#apsw.Connection.config" title="Link to this definition"></a></dt>
<dd><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>op</strong> – A <a class="reference external" href="https://sqlite.org/c3ref/c_dbconfig_enable_fkey.html">configuration operation</a></p></li>
<li><p><strong>args</strong> – Zero or more arguments as appropriate for <em>op</em></p></li>
</ul>
</dd>
</dl>
<p>This is how to get the fkey setting:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">val</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">config</span><span class="p">(</span><span class="n">apsw</span><span class="o">.</span><span class="n">SQLITE_DBCONFIG_ENABLE_FKEY</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<p>A parameter of zero would turn it off, 1 turns on, and negative
leaves unaltered.  The effective value is always returned.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/db_config.html">sqlite3_db_config</a></p>
</dd></dl>

<dl class="py method" id="index-12">
<dt class="sig sig-object py" id="apsw.Connection.create_aggregate_function">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">create_aggregate_function</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</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">factory</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.AggregateFactory" title="apsw.AggregateFactory"><span class="pre">AggregateFactory</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></em>, <em class="sig-param"><span class="n"><span class="pre">numargs</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#int" title="(in Python v3.12)"><span class="pre">int</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">-1</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">flags</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#int" title="(in Python v3.12)"><span class="pre">int</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">0</span></span></em><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="headerlink" href="#apsw.Connection.create_aggregate_function" title="Link to this definition"></a></dt>
<dd><p>Registers an aggregate function.  Aggregate functions operate on all
the relevant rows such as counting how many there are.</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>name</strong> – The string name of the function.  It should be less than 255 characters</p></li>
<li><p><strong>factory</strong> – The function that will be called.  Use None to delete the function.</p></li>
<li><p><strong>numargs</strong> – How many arguments the function takes, with -1 meaning any number</p></li>
<li><p><strong>flags</strong> – <a class="reference external" href="https://www.sqlite.org/c3ref/c_deterministic.html">Function flags</a></p></li>
</ul>
</dd>
</dl>
<p>When a query starts, the <em>factory</em> will be called.  It can return an object
with a <em>step</em> function called for each matching row, and a <em>final</em> function
to provide the final value.</p>
<p>Alternatively a non-class approach can return a tuple of 3 items:</p>
<blockquote>
<div><dl class="simple">
<dt>a context object</dt><dd><p>This can be of any type</p>
</dd>
<dt>a step function</dt><dd><p>This function is called once for each row.  The first parameter
will be the context object and the remaining parameters will be
from the SQL statement.  Any value returned will be ignored.</p>
</dd>
<dt>a final function</dt><dd><p>This function is called at the very end with the context object
as a parameter.  The value returned is set as the return for
the function. The final function is always called even if an
exception was raised by the step function. This allows you to
ensure any resources are cleaned up.</p>
</dd>
</dl>
</div></blockquote>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>You can register the same named function but with different
callables and <em>numargs</em>.  See
<a class="reference internal" href="#apsw.Connection.create_scalar_function" title="apsw.Connection.create_scalar_function"><code class="xref py py-meth docutils literal notranslate"><span class="pre">create_scalar_function()</span></code></a> for an example.</p>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="example.html#example-aggregate"><span class="std std-ref">Example</span></a></p></li>
<li><p><a class="reference internal" href="#apsw.Connection.create_scalar_function" title="apsw.Connection.create_scalar_function"><code class="xref py py-meth docutils literal notranslate"><span class="pre">create_scalar_function()</span></code></a></p></li>
<li><p><a class="reference internal" href="#apsw.Connection.create_window_function" title="apsw.Connection.create_window_function"><code class="xref py py-meth docutils literal notranslate"><span class="pre">create_window_function()</span></code></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/create_function.html">sqlite3_create_function_v2</a></p>
</dd></dl>

<dl class="py method" id="index-13">
<dt class="sig sig-object py" id="apsw.Connection.create_collation">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">create_collation</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</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">callback</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><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><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="p"><span class="pre">,</span></span><span class="w"> </span><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><span class="pre">int</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></em><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="headerlink" href="#apsw.Connection.create_collation" title="Link to this definition"></a></dt>
<dd><p>You can control how SQLite sorts (termed <a class="reference external" href="https://en.wikipedia.org/wiki/Collation">collation</a>) when giving the
<code class="docutils literal notranslate"><span class="pre">COLLATE</span></code> term to a <a class="reference external" href="https://sqlite.org/lang_select.html">SELECT</a>.  For example your
collation could take into account locale or do numeric sorting.</p>
<p>The <em>callback</em> will be called with two items.  It should return -1
if the first is less then the second, 0 if they are equal, and 1 if
first is greater:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">mycollation</span><span class="p">(</span><span class="n">first</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">two</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">int</span><span class="p">:</span>
    <span class="k">if</span> <span class="n">first</span> <span class="o">&lt;</span> <span class="n">second</span><span class="p">:</span>
        <span class="k">return</span> <span class="o">-</span><span class="mi">1</span>
    <span class="k">if</span> <span class="n">first</span> <span class="o">==</span> <span class="n">second</span><span class="p">:</span>
        <span class="k">return</span> <span class="mi">0</span>
    <span class="k">if</span> <span class="n">first</span> <span class="o">&gt;</span> <span class="n">second</span><span class="p">:</span>
        <span class="k">return</span> <span class="mi">1</span>
</pre></div>
</div>
<p>Passing None as the callback will unregister the collation.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="example.html#example-collation"><span class="std std-ref">Example</span></a></p></li>
<li><p><a class="reference internal" href="#apsw.Connection.collation_needed" title="apsw.Connection.collation_needed"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Connection.collation_needed()</span></code></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/create_collation.html">sqlite3_create_collation_v2</a></p>
</dd></dl>

<dl class="py method" id="index-14">
<dt class="sig sig-object py" id="apsw.Connection.create_module">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">create_module</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</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">datasource</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="vtable.html#apsw.VTModule" title="apsw.VTModule"><span class="pre">VTModule</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></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_bestindex_object</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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">use_no_change</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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">iVersion</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#int" title="(in Python v3.12)"><span class="pre">int</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">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eponymous</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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">eponymous_only</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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">read_only</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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em><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="headerlink" href="#apsw.Connection.create_module" title="Link to this definition"></a></dt>
<dd><p>Registers a virtual table, or drops it if <em>datasource</em> is <em>None</em>.
See <a class="reference internal" href="vtable.html#virtualtables"><span class="std std-ref">Virtual Tables</span></a> for details.</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>name</strong> – Module name (CREATE VIRTUAL TABLE table_name USING module_name…)</p></li>
<li><p><strong>datasource</strong> – Provides <a class="reference internal" href="vtable.html#apsw.VTModule" title="apsw.VTModule"><code class="xref py py-class docutils literal notranslate"><span class="pre">VTModule</span></code></a> methods</p></li>
<li><p><strong>use_bestindex_object</strong> – If True then BestIndexObject is used, else BestIndex</p></li>
<li><p><strong>use_no_change</strong> – Turn on understanding <a class="reference internal" href="vtable.html#apsw.VTCursor.ColumnNoChange" title="apsw.VTCursor.ColumnNoChange"><code class="xref py py-meth docutils literal notranslate"><span class="pre">VTCursor.ColumnNoChange()</span></code></a> and using <a class="reference internal" href="apsw.html#apsw.no_change" title="apsw.no_change"><code class="xref py py-attr docutils literal notranslate"><span class="pre">apsw.no_change</span></code></a> to reduce <a class="reference internal" href="vtable.html#apsw.VTTable.UpdateChangeRow" title="apsw.VTTable.UpdateChangeRow"><code class="xref py py-meth docutils literal notranslate"><span class="pre">VTTable.UpdateChangeRow()</span></code></a> work</p></li>
<li><p><strong>iVersion</strong> – iVersion field in <a class="reference external" href="https://www.sqlite.org/c3ref/module.html">sqlite3_module</a></p></li>
<li><p><strong>eponymous</strong> – Configures module to be <a class="reference external" href="https://www.sqlite.org/vtab.html#eponymous_virtual_tables">eponymous</a></p></li>
<li><p><strong>eponymous_only</strong> – Configures module to be <a class="reference external" href="https://www.sqlite.org/vtab.html#eponymous_only_virtual_tables">eponymous only</a></p></li>
<li><p><strong>read_only</strong> – Leaves <a class="reference external" href="https://www.sqlite.org/c3ref/module.html">sqlite3_module</a> methods that involve writing and transactions as NULL</p></li>
</ul>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="example.html#example-virtual-tables"><span class="std std-ref">Example</span></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/create_module.html">sqlite3_create_module_v2</a></p>
</dd></dl>

<dl class="py method" id="index-15">
<dt class="sig sig-object py" id="apsw.Connection.create_scalar_function">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">create_scalar_function</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</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">callable</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.ScalarProtocol" title="apsw.ScalarProtocol"><span class="pre">ScalarProtocol</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></em>, <em class="sig-param"><span class="n"><span class="pre">numargs</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#int" title="(in Python v3.12)"><span class="pre">int</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">-1</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">deterministic</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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">flags</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#int" title="(in Python v3.12)"><span class="pre">int</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">0</span></span></em><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="headerlink" href="#apsw.Connection.create_scalar_function" title="Link to this definition"></a></dt>
<dd><p>Registers a scalar function.  Scalar functions operate on one set of parameters once.</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>name</strong> – The string name of the function.  It should be less than 255 characters</p></li>
<li><p><strong>callable</strong> – The function that will be called.  Use None to unregister.</p></li>
<li><p><strong>numargs</strong> – How many arguments the function takes, with -1 meaning any number</p></li>
<li><p><strong>deterministic</strong> – When True this means the function always
returns the same result for the same input arguments.
SQLite’s query planner can perform additional optimisations
for deterministic functions.  For example a random()
function is not deterministic while one that returns the
length of a string is.</p></li>
<li><p><strong>flags</strong> – Additional <a class="reference external" href="https://www.sqlite.org/c3ref/c_deterministic.html">function flags</a></p></li>
</ul>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>You can register the same named function but with different
<em>callable</em> and <em>numargs</em>.  For example:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">connection</span><span class="o">.</span><span class="n">create_scalar_function</span><span class="p">(</span><span class="s2">&quot;toip&quot;</span><span class="p">,</span> <span class="n">ipv4convert</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span>
<span class="n">connection</span><span class="o">.</span><span class="n">create_scalar_function</span><span class="p">(</span><span class="s2">&quot;toip&quot;</span><span class="p">,</span> <span class="n">ipv6convert</span><span class="p">,</span> <span class="mi">16</span><span class="p">)</span>
<span class="n">connection</span><span class="o">.</span><span class="n">create_scalar_function</span><span class="p">(</span><span class="s2">&quot;toip&quot;</span><span class="p">,</span> <span class="n">strconvert</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>
</pre></div>
</div>
<p>The one with the correct <em>numargs</em> will be called and only if that
doesn’t exist then the one with negative <em>numargs</em> will be called.</p>
</div>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="example.html#example-scalar"><span class="std std-ref">Example</span></a></p></li>
<li><p><a class="reference internal" href="#apsw.Connection.create_aggregate_function" title="apsw.Connection.create_aggregate_function"><code class="xref py py-meth docutils literal notranslate"><span class="pre">create_aggregate_function()</span></code></a></p></li>
<li><p><a class="reference internal" href="#apsw.Connection.create_window_function" title="apsw.Connection.create_window_function"><code class="xref py py-meth docutils literal notranslate"><span class="pre">create_window_function()</span></code></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/create_function.html">sqlite3_create_function_v2</a></p>
</dd></dl>

<dl class="py method" id="index-16">
<dt class="sig sig-object py" id="apsw.Connection.create_window_function">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">create_window_function</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</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">factory</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.WindowFactory" title="apsw.WindowFactory"><span class="pre">WindowFactory</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></em>, <em class="sig-param"><span class="n"><span class="pre">numargs</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#int" title="(in Python v3.12)"><span class="pre">int</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">-1</span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">flags</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#int" title="(in Python v3.12)"><span class="pre">int</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">0</span></span></em><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="headerlink" href="#apsw.Connection.create_window_function" title="Link to this definition"></a></dt>
<dd><p>Registers a <a class="reference external" href="https://sqlite.org/windowfunctions.html#user_defined_aggregate_window_functions">window function</a></p>
<blockquote>
<div><dl class="field-list simple">
<dt class="field-odd">param name<span class="colon">:</span></dt>
<dd class="field-odd"><p>The string name of the function.  It should be less than 255 characters</p>
</dd>
<dt class="field-even">param factory<span class="colon">:</span></dt>
<dd class="field-even"><p>Called to start a new window.  Use None to delete the function.</p>
</dd>
<dt class="field-odd">param numargs<span class="colon">:</span></dt>
<dd class="field-odd"><p>How many arguments the function takes, with -1 meaning any number</p>
</dd>
<dt class="field-even">param flags<span class="colon">:</span></dt>
<dd class="field-even"><p><a class="reference external" href="https://www.sqlite.org/c3ref/c_deterministic.html">Function flags</a></p>
</dd>
</dl>
</div></blockquote>
<p>You need to provide callbacks for the <code class="docutils literal notranslate"><span class="pre">step</span></code>, <code class="docutils literal notranslate"><span class="pre">final</span></code>, <code class="docutils literal notranslate"><span class="pre">value</span></code>
and <code class="docutils literal notranslate"><span class="pre">inverse</span></code> methods.  This can be done by having <cite>factory</cite> as a
class, returning an instance with the corresponding method names, or by having <cite>factory</cite>
return a sequence of a first parameter, and then each of the 4
functions.</p>
<p><strong>Debugging note</strong> SQlite always calls the <code class="docutils literal notranslate"><span class="pre">final</span></code> method to allow
for cleanup.  If you have an exception in one of the other methods, then
<code class="docutils literal notranslate"><span class="pre">final</span></code> will also be called, and you may see both methods in
tracebacks.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="example.html#example-window"><span class="std std-ref">Example</span></a></p></li>
<li><p><a class="reference internal" href="#apsw.Connection.create_scalar_function" title="apsw.Connection.create_scalar_function"><code class="xref py py-meth docutils literal notranslate"><span class="pre">create_scalar_function()</span></code></a></p></li>
<li><p><a class="reference internal" href="#apsw.Connection.create_aggregate_function" title="apsw.Connection.create_aggregate_function"><code class="xref py py-meth docutils literal notranslate"><span class="pre">create_aggregate_function()</span></code></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/create_function.html">sqlite3_create_window_function</a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.Connection.cursor">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">cursor</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 internal" href="cursor.html#apsw.Cursor" title="apsw.Cursor"><span class="pre">Cursor</span></a></span></span><a class="headerlink" href="#apsw.Connection.cursor" title="Link to this definition"></a></dt>
<dd><p>Creates a new <a class="reference internal" href="cursor.html#apsw.Cursor" title="apsw.Cursor"><code class="xref py py-class docutils literal notranslate"><span class="pre">Cursor</span></code></a> object on this database.</p>
<dl class="field-list simple">
<dt class="field-odd">Return type<span class="colon">:</span></dt>
<dd class="field-odd"><p><a class="reference internal" href="cursor.html#apsw.Cursor" title="apsw.Cursor"><code class="xref py py-class docutils literal notranslate"><span class="pre">Cursor</span></code></a></p>
</dd>
</dl>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="apsw.Connection.cursor_factory">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">cursor_factory</span></span><em class="property"><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#apsw.Connection" title="apsw.Connection"><span class="pre">Connection</span></a><span class="p"><span class="pre">]</span></span><span class="p"><span class="pre">,</span></span><span class="w"> </span><span class="pre">Any</span><span class="p"><span class="pre">]</span></span></em><a class="headerlink" href="#apsw.Connection.cursor_factory" title="Link to this definition"></a></dt>
<dd><p>Defaults to <a class="reference internal" href="cursor.html#apsw.Cursor" title="apsw.Cursor"><code class="xref py py-class docutils literal notranslate"><span class="pre">Cursor</span></code></a></p>
<p>Called with a <a class="reference internal" href="#apsw.Connection" title="apsw.Connection"><code class="xref py py-class docutils literal notranslate"><span class="pre">Connection</span></code></a> as the only parameter when a cursor
is needed such as by the <a class="reference internal" href="#apsw.Connection.cursor" title="apsw.Connection.cursor"><code class="xref py py-meth docutils literal notranslate"><span class="pre">cursor()</span></code></a> method, or
<a class="reference internal" href="#apsw.Connection.execute" title="apsw.Connection.execute"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Connection.execute()</span></code></a>.</p>
<p>Note that whatever is returned doesn’t have to be an actual
<a class="reference internal" href="cursor.html#apsw.Cursor" title="apsw.Cursor"><code class="xref py py-class docutils literal notranslate"><span class="pre">Cursor</span></code></a> instance, and just needs to have the methods present
that are actually called.  These are likely to be <cite>execute</cite>,
<cite>executemany</cite>, <cite>close</cite> etc.</p>
</dd></dl>

<dl class="py method" id="index-17">
<dt class="sig sig-object py" id="apsw.Connection.db_filename">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">db_filename</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</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><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/stdtypes.html#str" title="(in Python v3.12)"><span class="pre">str</span></a></span></span><a class="headerlink" href="#apsw.Connection.db_filename" title="Link to this definition"></a></dt>
<dd><p>Returns the full filename of the named (attached) database.  The
main is <cite>main</cite>, <cite>temp</cite>, the name in <a class="reference external" href="https://sqlite.org/lang_attach.html">ATTACH</a></p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/db_filename.html">sqlite3_db_filename</a></p>
</dd></dl>

<dl class="py method" id="index-18">
<dt class="sig sig-object py" id="apsw.Connection.db_names">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">db_names</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/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></span><a class="headerlink" href="#apsw.Connection.db_names" title="Link to this definition"></a></dt>
<dd><p>Returns the list of database names.  For example the first database
is named ‘main’, the next ‘temp’, and the rest with the name provided
in <a class="reference external" href="https://www.sqlite.org/lang_attach.html">ATTACH</a></p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/db_name.html">sqlite3_db_name</a></p>
</dd></dl>

<dl class="py method" id="index-19">
<dt class="sig sig-object py" id="apsw.Connection.deserialize">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">deserialize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</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">contents</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#bytes" title="(in Python v3.12)"><span class="pre">bytes</span></a></span></em><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="headerlink" href="#apsw.Connection.deserialize" title="Link to this definition"></a></dt>
<dd><p>Replaces the named database with an in-memory copy of <em>contents</em>.
<em>name</em> is <cite>main</cite>, <cite>temp</cite>, the name in <a class="reference external" href="https://sqlite.org/lang_attach.html">ATTACH</a></p>
<p>The resulting database is in-memory, read-write, and the memory is
owned, resized, and freed by SQLite.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="#apsw.Connection.serialize" title="apsw.Connection.serialize"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Connection.serialize()</span></code></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/deserialize.html">sqlite3_deserialize</a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.Connection.drop_modules">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">drop_modules</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">keep</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Iterable</span><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></em><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="headerlink" href="#apsw.Connection.drop_modules" title="Link to this definition"></a></dt>
<dd><p>If <em>keep</em> is <em>None</em> then all registered virtual tables are dropped.</p>
<p>Otherwise <em>keep</em> is a sequence of strings, naming the virtual tables that
are kept, dropping all others.</p>
</dd></dl>

<dl class="py method" id="index-20">
<dt class="sig sig-object py" id="apsw.Connection.enable_load_extension">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">enable_load_extension</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">enable</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><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="headerlink" href="#apsw.Connection.enable_load_extension" title="Link to this definition"></a></dt>
<dd><p>Enables/disables <a class="reference external" href="https://www.sqlite.org/loadext.html">extension loading</a>
which is disabled by default.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>enable</strong> – If True then extension loading is enabled, else it is disabled.</p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="#apsw.Connection.load_extension" title="apsw.Connection.load_extension"><code class="xref py py-meth docutils literal notranslate"><span class="pre">load_extension()</span></code></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/enable_load_extension.html">sqlite3_enable_load_extension</a></p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="apsw.Connection.exec_trace">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">exec_trace</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.ExecTracer" title="apsw.ExecTracer"><span class="pre">ExecTracer</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></em><a class="headerlink" href="#apsw.Connection.exec_trace" title="Link to this definition"></a></dt>
<dd><p>Called with the cursor, statement and bindings for
each <a class="reference internal" href="cursor.html#apsw.Cursor.execute" title="apsw.Cursor.execute"><code class="xref py py-meth docutils literal notranslate"><span class="pre">execute()</span></code></a> or <a class="reference internal" href="cursor.html#apsw.Cursor.executemany" title="apsw.Cursor.executemany"><code class="xref py py-meth docutils literal notranslate"><span class="pre">executemany()</span></code></a> on this
Connection, unless the <a class="reference internal" href="cursor.html#apsw.Cursor" title="apsw.Cursor"><code class="xref py py-class docutils literal notranslate"><span class="pre">Cursor</span></code></a> installed its own
tracer. Your execution tracer can also abort execution of a
statement.</p>
<p>If <em>callable</em> is <em>None</em> then any existing execution tracer is
removed.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="execution.html#tracing"><span class="std std-ref">Tracing</span></a></p></li>
<li><p><a class="reference internal" href="execution.html#rowtracer"><span class="std std-ref">Row Tracer</span></a></p></li>
<li><p><a class="reference internal" href="cursor.html#apsw.Cursor.exec_trace" title="apsw.Cursor.exec_trace"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Cursor.exec_trace</span></code></a></p></li>
</ul>
</div>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.Connection.execute">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">execute</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">statements</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="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><a class="reference internal" href="apsw.html#apsw.Bindings" title="apsw.Bindings"><span class="pre">Bindings</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="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">can_cache</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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prepare_flags</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#int" title="(in Python v3.12)"><span class="pre">int</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">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">explain</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#int" title="(in Python v3.12)"><span class="pre">int</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">-1</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="cursor.html#apsw.Cursor" title="apsw.Cursor"><span class="pre">Cursor</span></a></span></span><a class="headerlink" href="#apsw.Connection.execute" title="Link to this definition"></a></dt>
<dd><p>Executes the statements using the supplied bindings.  Execution
returns when the first row is available or all statements have
completed.  (A cursor is automatically obtained).</p>
<p>For pragmas you should use <a class="reference internal" href="#apsw.Connection.pragma" title="apsw.Connection.pragma"><code class="xref py py-meth docutils literal notranslate"><span class="pre">pragma()</span></code></a> which handles quoting and
caching correctly.</p>
<p>See <a class="reference internal" href="cursor.html#apsw.Cursor.execute" title="apsw.Cursor.execute"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Cursor.execute()</span></code></a> for more details, and the <a class="reference internal" href="example.html#example-executing-sql"><span class="std std-ref">example</span></a>.</p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.Connection.executemany">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">executemany</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">statements</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">sequenceofbindings</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Iterable</span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="apsw.html#apsw.Bindings" title="apsw.Bindings"><span class="pre">Bindings</span></a><span class="p"><span class="pre">]</span></span></span></em>, <em class="sig-param"><span class="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">can_cache</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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">True</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">prepare_flags</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#int" title="(in Python v3.12)"><span class="pre">int</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">0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">explain</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#int" title="(in Python v3.12)"><span class="pre">int</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">-1</span></span></em><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><a class="reference internal" href="cursor.html#apsw.Cursor" title="apsw.Cursor"><span class="pre">Cursor</span></a></span></span><a class="headerlink" href="#apsw.Connection.executemany" title="Link to this definition"></a></dt>
<dd></dd></dl>

<p>This method is for when you want to execute the same statements over a
sequence of bindings, such as inserting into a database.  (A cursor is
automatically obtained).</p>
<p>See <a class="reference internal" href="cursor.html#apsw.Cursor.executemany" title="apsw.Cursor.executemany"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Cursor.executemany()</span></code></a> for more details, and the <a class="reference internal" href="example.html#example-executemany"><span class="std std-ref">example</span></a>.</p>
<dl class="py method" id="index-21">
<dt class="sig sig-object py" id="apsw.Connection.file_control">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">file_control</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dbname</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">op</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#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">pointer</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#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em><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/functions.html#bool" title="(in Python v3.12)"><span class="pre">bool</span></a></span></span><a class="headerlink" href="#apsw.Connection.file_control" title="Link to this definition"></a></dt>
<dd><p>Calls the <a class="reference internal" href="vfs.html#apsw.VFSFile.xFileControl" title="apsw.VFSFile.xFileControl"><code class="xref py py-meth docutils literal notranslate"><span class="pre">xFileControl()</span></code></a> method on the <a class="reference internal" href="vfs.html#vfs"><span class="std std-ref">Virtual File System (VFS)</span></a>
implementing <a class="reference internal" href="vfs.html#apsw.VFSFile" title="apsw.VFSFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">file</span> <span class="pre">access</span></code></a> for the database.</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>dbname</strong> – The name of the database to affect.  <cite>main</cite>, <cite>temp</cite>, the name in <a class="reference external" href="https://sqlite.org/lang_attach.html">ATTACH</a></p></li>
<li><p><strong>op</strong> – A <a class="reference external" href="https://sqlite.org/c3ref/c_fcntl_lockstate.html">numeric code</a> with values less
than 100 reserved for SQLite internal use.</p></li>
<li><p><strong>pointer</strong> – A number which is treated as a <code class="docutils literal notranslate"><span class="pre">void</span> <span class="pre">pointer</span></code> at the C level.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>True or False indicating if the VFS understood the op.</p>
</dd>
</dl>
<p>The <a class="reference internal" href="example.html#example-filecontrol"><span class="std std-ref">example</span></a> shows getting
<a class="reference external" href="https://sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntldataversion">SQLITE_FCNTL_DATA_VERSION</a>.</p>
<p>If you want data returned back then the <em>pointer</em> needs to point to
something mutable.  Here is an example using <a class="reference external" href="https://docs.python.org/3/library/ctypes.html">ctypes</a> of
passing a Python dictionary to <a class="reference internal" href="vfs.html#apsw.VFSFile.xFileControl" title="apsw.VFSFile.xFileControl"><code class="xref py py-meth docutils literal notranslate"><span class="pre">xFileControl()</span></code></a> which
can then modify the dictionary to set return values:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">obj</span><span class="o">=</span><span class="p">{</span><span class="s2">&quot;foo&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">:</span> <span class="mi">3</span><span class="p">}</span>                 <span class="c1"># object we want to pass</span>
<span class="n">objwrap</span><span class="o">=</span><span class="n">ctypes</span><span class="o">.</span><span class="n">py_object</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span>        <span class="c1"># objwrap must live before and after the call else</span>
                                     <span class="c1"># it gets garbage collected</span>
<span class="n">connection</span><span class="o">.</span><span class="n">file_control</span><span class="p">(</span>
         <span class="s2">&quot;main&quot;</span><span class="p">,</span>                     <span class="c1"># which db</span>
         <span class="mi">123</span><span class="p">,</span>                        <span class="c1"># our op code</span>
         <span class="n">ctypes</span><span class="o">.</span><span class="n">addressof</span><span class="p">(</span><span class="n">objwrap</span><span class="p">))</span>  <span class="c1"># get pointer</span>
</pre></div>
</div>
<p>The <a class="reference internal" href="vfs.html#apsw.VFSFile.xFileControl" title="apsw.VFSFile.xFileControl"><code class="xref py py-meth docutils literal notranslate"><span class="pre">xFileControl()</span></code></a> method then looks like this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">xFileControl</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">op</span><span class="p">,</span> <span class="n">pointer</span><span class="p">):</span>
    <span class="k">if</span> <span class="n">op</span><span class="o">==</span><span class="mi">123</span><span class="p">:</span>                      <span class="c1"># our op code</span>
        <span class="n">obj</span><span class="o">=</span><span class="n">ctypes</span><span class="o">.</span><span class="n">py_object</span><span class="o">.</span><span class="n">from_address</span><span class="p">(</span><span class="n">pointer</span><span class="p">)</span><span class="o">.</span><span class="n">value</span>
        <span class="c1"># play with obj - you can use id() to verify it is the same</span>
        <span class="nb">print</span><span class="p">(</span><span class="n">obj</span><span class="p">[</span><span class="s2">&quot;foo&quot;</span><span class="p">])</span>
        <span class="n">obj</span><span class="p">[</span><span class="s2">&quot;result&quot;</span><span class="p">]</span><span class="o">=</span><span class="s2">&quot;it worked&quot;</span>
        <span class="k">return</span> <span class="kc">True</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="c1"># pass to parent/superclass</span>
        <span class="k">return</span> <span class="nb">super</span><span class="p">()</span><span class="o">.</span><span class="n">xFileControl</span><span class="p">(</span><span class="n">op</span><span class="p">,</span> <span class="n">pointer</span><span class="p">)</span>
</pre></div>
</div>
<p>This is how you set the chunk size by which the database grows.  Do
not combine it into one line as the c_int would be garbage collected
before the file control call is made:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">chunksize</span><span class="o">=</span><span class="n">ctypes</span><span class="o">.</span><span class="n">c_int</span><span class="p">(</span><span class="mi">32768</span><span class="p">)</span>
<span class="n">connection</span><span class="o">.</span><span class="n">file_control</span><span class="p">(</span><span class="s2">&quot;main&quot;</span><span class="p">,</span> <span class="n">apsw</span><span class="o">.</span><span class="n">SQLITE_FCNTL_CHUNK_SIZE</span><span class="p">,</span> <span class="n">ctypes</span><span class="o">.</span><span class="n">addressof</span><span class="p">(</span><span class="n">chunksize</span><span class="p">))</span>
</pre></div>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/file_control.html">sqlite3_file_control</a></p>
</dd></dl>

<dl class="py attribute" id="index-22">
<dt class="sig sig-object py" id="apsw.Connection.filename">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">filename</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#str" title="(in Python v3.12)"><span class="pre">str</span></a></em><a class="headerlink" href="#apsw.Connection.filename" title="Link to this definition"></a></dt>
<dd><p>The filename of the database.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/db_filename.html">sqlite3_db_filename</a></p>
</dd></dl>

<dl class="py attribute" id="index-23">
<dt class="sig sig-object py" id="apsw.Connection.filename_journal">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">filename_journal</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#str" title="(in Python v3.12)"><span class="pre">str</span></a></em><a class="headerlink" href="#apsw.Connection.filename_journal" title="Link to this definition"></a></dt>
<dd><p>The journal filename of the database,</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/filename_database.html">sqlite3_filename_journal</a></p>
</dd></dl>

<dl class="py attribute" id="index-24">
<dt class="sig sig-object py" id="apsw.Connection.filename_wal">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">filename_wal</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#str" title="(in Python v3.12)"><span class="pre">str</span></a></em><a class="headerlink" href="#apsw.Connection.filename_wal" title="Link to this definition"></a></dt>
<dd><p>The WAL filename of the database,</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/filename_database.html">sqlite3_filename_wal</a></p>
</dd></dl>

<dl class="py method" id="index-25">
<dt class="sig sig-object py" id="apsw.Connection.get_autocommit">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">get_autocommit</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/functions.html#bool" title="(in Python v3.12)"><span class="pre">bool</span></a></span></span><a class="headerlink" href="#apsw.Connection.get_autocommit" title="Link to this definition"></a></dt>
<dd><p>Returns if the Connection is in auto commit mode (ie not in a transaction).</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/get_autocommit.html">sqlite3_get_autocommit</a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.Connection.get_exec_trace">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">get_exec_trace</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 internal" href="apsw.html#apsw.ExecTracer" title="apsw.ExecTracer"><span class="pre">ExecTracer</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><a class="headerlink" href="#apsw.Connection.get_exec_trace" title="Link to this definition"></a></dt>
<dd><p>Returns the currently installed <a class="reference internal" href="#apsw.Connection.exec_trace" title="apsw.Connection.exec_trace"><code class="xref py py-attr docutils literal notranslate"><span class="pre">execution</span> <span class="pre">tracer</span></code></a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.Connection.get_row_trace">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">get_row_trace</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 internal" href="apsw.html#apsw.RowTracer" title="apsw.RowTracer"><span class="pre">RowTracer</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><a class="headerlink" href="#apsw.Connection.get_row_trace" title="Link to this definition"></a></dt>
<dd><p>Returns the currently installed <a class="reference internal" href="#apsw.Connection.row_trace" title="apsw.Connection.row_trace"><code class="xref py py-attr docutils literal notranslate"><span class="pre">row</span> <span class="pre">tracer</span></code></a></p>
</dd></dl>

<dl class="py attribute" id="index-26">
<dt class="sig sig-object py" id="apsw.Connection.in_transaction">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">in_transaction</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.Connection.in_transaction" title="Link to this definition"></a></dt>
<dd><p>True if currently in a transaction, else False</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/get_autocommit.html">sqlite3_get_autocommit</a></p>
</dd></dl>

<dl class="py method" id="index-27">
<dt class="sig sig-object py" id="apsw.Connection.interrupt">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">interrupt</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="headerlink" href="#apsw.Connection.interrupt" title="Link to this definition"></a></dt>
<dd><p>Causes all pending operations on the database to abort at the
earliest opportunity. You can call this from any thread.  For
example you may have a long running query when the user presses the
stop button in your user interface.  <a class="reference internal" href="exceptions.html#apsw.InterruptError" title="apsw.InterruptError"><code class="xref py py-exc docutils literal notranslate"><span class="pre">InterruptError</span></code></a>
will be raised in the queries that got interrupted.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/interrupt.html">sqlite3_interrupt</a></p>
</dd></dl>

<dl class="py attribute" id="index-28">
<dt class="sig sig-object py" id="apsw.Connection.is_interrupted">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">is_interrupted</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.Connection.is_interrupted" title="Link to this definition"></a></dt>
<dd><p>Indicates if this connection has been interrupted.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/interrupt.html">sqlite3_is_interrupted</a></p>
</dd></dl>

<dl class="py method" id="index-29">
<dt class="sig sig-object py" id="apsw.Connection.last_insert_rowid">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">last_insert_rowid</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/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></span><a class="headerlink" href="#apsw.Connection.last_insert_rowid" title="Link to this definition"></a></dt>
<dd><p>Returns the integer key of the most recent insert in the database.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/last_insert_rowid.html">sqlite3_last_insert_rowid</a></p>
</dd></dl>

<dl class="py method" id="index-30">
<dt class="sig sig-object py" id="apsw.Connection.limit">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">limit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">id</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#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">newval</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#int" title="(in Python v3.12)"><span class="pre">int</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">-1</span></span></em><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/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></span><a class="headerlink" href="#apsw.Connection.limit" title="Link to this definition"></a></dt>
<dd><p>If called with one parameter then the current limit for that <em>id</em> is
returned.  If called with two then the limit is set to <em>newval</em>.</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>id</strong> – One of the <a class="reference external" href="https://sqlite.org/c3ref/c_limit_attached.html">runtime limit ids</a></p></li>
<li><p><strong>newval</strong> – The new limit.  This is a 32 bit signed integer even on 64 bit platforms.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>The limit in place on entry to the call.</p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="example.html#example-limits"><span class="std std-ref">Example</span></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/limit.html">sqlite3_limit</a></p>
</dd></dl>

<dl class="py method" id="index-31">
<dt class="sig sig-object py" id="apsw.Connection.load_extension">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">load_extension</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">filename</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">entrypoint</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 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> <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="headerlink" href="#apsw.Connection.load_extension" title="Link to this definition"></a></dt>
<dd><p>Loads <em>filename</em> as an <a class="reference external" href="https://www.sqlite.org/loadext.html">extension</a></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>filename</strong> – The file to load.</p></li>
<li><p><strong>entrypoint</strong> – The initialization method to call.  If this
parameter is not supplied then the SQLite default of
<code class="docutils literal notranslate"><span class="pre">sqlite3_extension_init</span></code> is used.</p></li>
</ul>
</dd>
<dt class="field-even">Raises<span class="colon">:</span></dt>
<dd class="field-even"><p><a class="reference internal" href="exceptions.html#apsw.ExtensionLoadingError" title="apsw.ExtensionLoadingError"><strong>ExtensionLoadingError</strong></a> – If the extension could not be
loaded.  The exception string includes more details.</p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="#apsw.Connection.enable_load_extension" title="apsw.Connection.enable_load_extension"><code class="xref py py-meth docutils literal notranslate"><span class="pre">enable_load_extension()</span></code></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/load_extension.html">sqlite3_load_extension</a></p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="apsw.Connection.open_flags">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">open_flags</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#int" title="(in Python v3.12)"><span class="pre">int</span></a></em><a class="headerlink" href="#apsw.Connection.open_flags" title="Link to this definition"></a></dt>
<dd><p>The combination of <a class="reference internal" href="apsw.html#apsw.mapping_open_flags" title="apsw.mapping_open_flags"><code class="xref py py-attr docutils literal notranslate"><span class="pre">flags</span></code></a> used to open the database.</p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="apsw.Connection.open_vfs">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">open_vfs</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#str" title="(in Python v3.12)"><span class="pre">str</span></a></em><a class="headerlink" href="#apsw.Connection.open_vfs" title="Link to this definition"></a></dt>
<dd><p>The string name of the vfs used to open the database.</p>
</dd></dl>

<dl class="py method" id="index-32">
<dt class="sig sig-object py" id="apsw.Connection.overload_function">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">overload_function</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</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">nargs</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#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em><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="headerlink" href="#apsw.Connection.overload_function" title="Link to this definition"></a></dt>
<dd><p>Registers a placeholder function so that a virtual table can provide an implementation via
<a class="reference internal" href="vtable.html#apsw.VTTable.FindFunction" title="apsw.VTTable.FindFunction"><code class="xref py py-meth docutils literal notranslate"><span class="pre">VTTable.FindFunction()</span></code></a>.</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>name</strong> – Function name</p></li>
<li><p><strong>nargs</strong> – How many arguments the function takes</p></li>
</ul>
</dd>
</dl>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/overload_function.html">sqlite3_overload_function</a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.Connection.pragma">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">pragma</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</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">value</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.SQLiteValue" title="apsw.SQLiteValue"><span class="pre">SQLiteValue</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="o"><span class="pre">*</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">schema</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 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> <span class="sig-return"><span class="sig-return-icon">&#x2192;</span> <span class="sig-return-typehint"><span class="pre">Any</span></span></span><a class="headerlink" href="#apsw.Connection.pragma" title="Link to this definition"></a></dt>
<dd><p>Issues the pragma (with the value if supplied) and returns the result with
<a class="reference internal" href="cursor.html#apsw.Cursor.get" title="apsw.Cursor.get"><code class="xref py py-attr docutils literal notranslate"><span class="pre">the</span> <span class="pre">least</span> <span class="pre">amount</span> <span class="pre">of</span> <span class="pre">structure</span></code></a>.  For example
<code class="code docutils literal notranslate"><span class="pre">pragma(&quot;user_version&quot;)</span></code> will return just the number, while
<code class="code docutils literal notranslate"><span class="pre">pragma(&quot;journal_mode&quot;,</span> <span class="pre">&quot;WAL&quot;)</span></code> will return the journal mode
now in effect.</p>
<p>Pragmas do not support bindings, so this method is a convenient
alternative to composing SQL text.  Pragmas are often executed
while being prepared, instead of when run like regular SQL.  They
may also contain encryption keys.  This method ensures they are
not cached to avoid problems.</p>
<p>Use the <cite>schema</cite> parameter to run the pragma against a different
attached database (eg <code class="docutils literal notranslate"><span class="pre">temp</span></code>).</p>
<ul class="simple">
<li><p><a class="reference internal" href="example.html#example-pragma"><span class="std std-ref">Example</span></a></p></li>
</ul>
</dd></dl>

<dl class="py method" id="index-33">
<dt class="sig sig-object py" id="apsw.Connection.read">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">read</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">schema</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">which</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#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">offset</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#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">amount</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#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em><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/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/functions.html#bool" title="(in Python v3.12)"><span class="pre">bool</span></a><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#bytes" title="(in Python v3.12)"><span class="pre">bytes</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#apsw.Connection.read" title="Link to this definition"></a></dt>
<dd><p>Invokes the underlying VFS method to read data from the database.  It
is strongly recommended to read aligned complete pages, since that is
only what SQLite does.</p>
<p><cite>schema</cite> is <cite>main</cite>, <cite>temp</cite>, the name in <a class="reference external" href="https://sqlite.org/lang_attach.html">ATTACH</a></p>
<p><cite>which</cite> is 0 for the database file, 1 for the journal.</p>
<p>The return value is a tuple of a boolean indicating a complete read if
True, and the bytes read which will always be the amount requested
in size.</p>
<p><cite>SQLITE_IOERR_SHORT_READ</cite> will give a <cite>False</cite> value for the boolean,
and there is no way of knowing how much was read.</p>
<p>Implemented using <cite>SQLITE_FCNTL_FILE_POINTER</cite> and <cite>SQLITE_FCNTL_JOURNAL_POINTER</cite>.
Errors will usually be generic <cite>SQLITE_ERROR</cite> with no message.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/file_control.html">sqlite3_file_control</a></p>
</dd></dl>

<dl class="py method" id="index-34">
<dt class="sig sig-object py" id="apsw.Connection.readonly">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">readonly</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</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><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/functions.html#bool" title="(in Python v3.12)"><span class="pre">bool</span></a></span></span><a class="headerlink" href="#apsw.Connection.readonly" title="Link to this definition"></a></dt>
<dd><p>True or False if the named (attached) database was opened readonly or file
permissions don’t allow writing.  The name is <cite>main</cite>, <cite>temp</cite>, the
name in <a class="reference external" href="https://sqlite.org/lang_attach.html">ATTACH</a></p>
<p>An exception is raised if the database doesn’t exist.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/db_readonly.html">sqlite3_db_readonly</a></p>
</dd></dl>

<dl class="py method" id="index-35">
<dt class="sig sig-object py" id="apsw.Connection.release_memory">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">release_memory</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="headerlink" href="#apsw.Connection.release_memory" title="Link to this definition"></a></dt>
<dd><p>Attempts to free as much heap memory as possible used by this connection.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/db_release_memory.html">sqlite3_db_release_memory</a></p>
</dd></dl>

<dl class="py attribute">
<dt class="sig sig-object py" id="apsw.Connection.row_trace">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">row_trace</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.RowTracer" title="apsw.RowTracer"><span class="pre">RowTracer</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></em><a class="headerlink" href="#apsw.Connection.row_trace" title="Link to this definition"></a></dt>
<dd><p>Called with the cursor and row being returned for
<a class="reference internal" href="cursor.html#apsw.Cursor" title="apsw.Cursor"><code class="xref py py-class docutils literal notranslate"><span class="pre">cursors</span></code></a> associated with this Connection, unless
the Cursor installed its own tracer.  You can change the data that
is returned or cause the row to be skipped altogether.</p>
<p>If <em>callable</em> is <em>None</em> then any existing row tracer is
removed.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="execution.html#tracing"><span class="std std-ref">Tracing</span></a></p></li>
<li><p><a class="reference internal" href="execution.html#rowtracer"><span class="std std-ref">Row Tracer</span></a></p></li>
<li><p><a class="reference internal" href="cursor.html#apsw.Cursor.exec_trace" title="apsw.Cursor.exec_trace"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Cursor.exec_trace</span></code></a></p></li>
</ul>
</div>
</dd></dl>

<dl class="py method" id="index-36">
<dt class="sig sig-object py" id="apsw.Connection.serialize">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">serialize</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">name</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><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/stdtypes.html#bytes" title="(in Python v3.12)"><span class="pre">bytes</span></a></span></span><a class="headerlink" href="#apsw.Connection.serialize" title="Link to this definition"></a></dt>
<dd><p>Returns a memory copy of the database. <em>name</em> is <cite>main</cite>, <cite>temp</cite>, the name
in <a class="reference external" href="https://sqlite.org/lang_attach.html">ATTACH</a></p>
<p>The memory copy is the same as if the database was backed up to
disk.</p>
<p>If the database name doesn’t exist, then None is returned, not an
exception (this is SQLite’s behaviour).  One exception is than an
empty temp will result in a None return.</p>
<blockquote>
<div><div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="#apsw.Connection.deserialize" title="apsw.Connection.deserialize"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Connection.deserialize()</span></code></a></p></li>
</ul>
</div>
</div></blockquote>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/serialize.html">sqlite3_serialize</a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.Connection.set_authorizer">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">set_authorizer</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">callable</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.Authorizer" title="apsw.Authorizer"><span class="pre">Authorizer</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></em><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="headerlink" href="#apsw.Connection.set_authorizer" title="Link to this definition"></a></dt>
<dd><p>Sets the <a class="reference internal" href="#apsw.Connection.authorizer" title="apsw.Connection.authorizer"><code class="xref py py-attr docutils literal notranslate"><span class="pre">authorizer</span></code></a></p>
</dd></dl>

<dl class="py method" id="index-37">
<dt class="sig sig-object py" id="apsw.Connection.set_busy_handler">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">set_busy_handler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">callable</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a><span class="p"><span class="pre">]</span></span><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><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></em><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="headerlink" href="#apsw.Connection.set_busy_handler" title="Link to this definition"></a></dt>
<dd><p>Sets the busy handler to callable. callable will be called with one
integer argument which is the number of prior calls to the busy
callback for the same lock. If the busy callback returns False,
then SQLite returns <em>SQLITE_BUSY</em> to the calling code. If
the callback returns True, then SQLite tries to open the table
again and the cycle repeats.</p>
<p>If you previously called <a class="reference internal" href="#apsw.Connection.set_busy_timeout" title="apsw.Connection.set_busy_timeout"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_busy_timeout()</span></code></a> then
calling this overrides that.</p>
<p>Passing None unregisters the existing handler.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="#apsw.Connection.set_busy_timeout" title="apsw.Connection.set_busy_timeout"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Connection.set_busy_timeout()</span></code></a></p></li>
<li><p><a class="reference internal" href="tips.html#busyhandling"><span class="std std-ref">Busy handling</span></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/busy_handler.html">sqlite3_busy_handler</a></p>
</dd></dl>

<dl class="py method" id="index-38">
<dt class="sig sig-object py" id="apsw.Connection.set_busy_timeout">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">set_busy_timeout</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">milliseconds</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#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em><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="headerlink" href="#apsw.Connection.set_busy_timeout" title="Link to this definition"></a></dt>
<dd><p>If the database is locked such as when another connection is making
changes, SQLite will keep retrying.  This sets the maximum amount of
time SQLite will keep retrying before giving up.  If the database is
still busy then <a class="reference internal" href="exceptions.html#apsw.BusyError" title="apsw.BusyError"><code class="xref py py-class docutils literal notranslate"><span class="pre">apsw.BusyError</span></code></a> will be returned.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>milliseconds</strong> – Maximum thousandths of a second to wait.</p>
</dd>
</dl>
<p>If you previously called <a class="reference internal" href="#apsw.Connection.set_busy_handler" title="apsw.Connection.set_busy_handler"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set_busy_handler()</span></code></a> then
calling this overrides that.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="#apsw.Connection.set_busy_handler" title="apsw.Connection.set_busy_handler"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Connection.set_busy_handler()</span></code></a></p></li>
<li><p><a class="reference internal" href="tips.html#busyhandling"><span class="std std-ref">Busy handling</span></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/busy_timeout.html">sqlite3_busy_timeout</a></p>
</dd></dl>

<dl class="py method" id="index-39">
<dt class="sig sig-object py" id="apsw.Connection.set_commit_hook">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">set_commit_hook</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">callable</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.CommitHook" title="apsw.CommitHook"><span class="pre">CommitHook</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></em><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="headerlink" href="#apsw.Connection.set_commit_hook" title="Link to this definition"></a></dt>
<dd><p><em>callable</em> will be called just before a commit.  It should return
False for the commit to go ahead and True for it to be turned
into a rollback. In the case of an exception in your callable, a
True (rollback) value is returned.  Pass None to unregister
the existing hook.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="example.html#example-commit-hook"><span class="std std-ref">Example</span></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/commit_hook.html">sqlite3_commit_hook</a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.Connection.set_exec_trace">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">set_exec_trace</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">callable</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.ExecTracer" title="apsw.ExecTracer"><span class="pre">ExecTracer</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></em><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="headerlink" href="#apsw.Connection.set_exec_trace" title="Link to this definition"></a></dt>
<dd><p>Method to set <a class="reference internal" href="#apsw.Connection.exec_trace" title="apsw.Connection.exec_trace"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Connection.exec_trace</span></code></a></p>
</dd></dl>

<dl class="py method" id="index-40">
<dt class="sig sig-object py" id="apsw.Connection.set_last_insert_rowid">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">set_last_insert_rowid</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">rowid</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#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em><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="headerlink" href="#apsw.Connection.set_last_insert_rowid" title="Link to this definition"></a></dt>
<dd><p>Sets the value calls to <a class="reference internal" href="#apsw.Connection.last_insert_rowid" title="apsw.Connection.last_insert_rowid"><code class="xref py py-meth docutils literal notranslate"><span class="pre">last_insert_rowid()</span></code></a> will return.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/set_last_insert_rowid.html">sqlite3_set_last_insert_rowid</a></p>
</dd></dl>

<dl class="py method" id="index-41">
<dt class="sig sig-object py" id="apsw.Connection.set_profile">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">set_profile</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">callable</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><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><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a><span class="p"><span class="pre">]</span></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 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></em><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="headerlink" href="#apsw.Connection.set_profile" title="Link to this definition"></a></dt>
<dd><p>Sets a callable which is invoked at the end of execution of each
statement and passed the statement string and how long it took to
execute. (The execution time is in nanoseconds.) Note that it is
called only on completion. If for example you do a <code class="docutils literal notranslate"><span class="pre">SELECT</span></code> and only
read the first result, then you won’t reach the end of the statement.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/trace_v2.html">sqlite3_trace_v2</a></p>
</dd></dl>

<dl class="py method" id="index-42">
<dt class="sig sig-object py" id="apsw.Connection.set_progress_handler">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">set_progress_handler</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">callable</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">]</span></span><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><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></em>, <em class="sig-param"><span class="n"><span class="pre">nsteps</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#int" title="(in Python v3.12)"><span class="pre">int</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">20</span></span></em><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="headerlink" href="#apsw.Connection.set_progress_handler" title="Link to this definition"></a></dt>
<dd><p>Sets a callable which is invoked every <em>nsteps</em> SQLite
inststructions. The callable should return True to abort
or False to continue. (If there is an error in your Python <em>callable</em>
then True/abort will be returned).</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="example.html#example-progress-handler"><span class="std std-ref">Example</span></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/progress_handler.html">sqlite3_progress_handler</a></p>
</dd></dl>

<dl class="py method" id="index-43">
<dt class="sig sig-object py" id="apsw.Connection.set_rollback_hook">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">set_rollback_hook</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">callable</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">]</span></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 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></em><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="headerlink" href="#apsw.Connection.set_rollback_hook" title="Link to this definition"></a></dt>
<dd><p>Sets a callable which is invoked during a rollback.  If <em>callable</em>
is <em>None</em> then any existing rollback hook is unregistered.</p>
<p>The <em>callable</em> is called with no parameters and the return value is ignored.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/commit_hook.html">sqlite3_rollback_hook</a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.Connection.set_row_trace">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">set_row_trace</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">callable</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.RowTracer" title="apsw.RowTracer"><span class="pre">RowTracer</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></em><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="headerlink" href="#apsw.Connection.set_row_trace" title="Link to this definition"></a></dt>
<dd><p>Method to set <a class="reference internal" href="#apsw.Connection.row_trace" title="apsw.Connection.row_trace"><code class="xref py py-attr docutils literal notranslate"><span class="pre">Connection.row_trace</span></code></a></p>
</dd></dl>

<dl class="py method" id="index-44">
<dt class="sig sig-object py" id="apsw.Connection.set_update_hook">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">set_update_hook</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">callable</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a><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#str" title="(in Python v3.12)"><span class="pre">str</span></a><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#str" title="(in Python v3.12)"><span class="pre">str</span></a><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#int" title="(in Python v3.12)"><span class="pre">int</span></a><span class="p"><span class="pre">]</span></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 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></em><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="headerlink" href="#apsw.Connection.set_update_hook" title="Link to this definition"></a></dt>
<dd><p>Calls <em>callable</em> whenever a row is updated, deleted or inserted.  If
<em>callable</em> is <em>None</em> then any existing update hook is
unregistered.  The update hook cannot make changes to the database while
the query is still executing, but can record them for later use or
apply them in a different connection.</p>
<p>The update hook is called with 4 parameters:</p>
<blockquote>
<div><dl class="simple">
<dt>type (int)</dt><dd><p><em>SQLITE_INSERT</em>, <em>SQLITE_DELETE</em> or <em>SQLITE_UPDATE</em></p>
</dd>
<dt>database name (str)</dt><dd><p><cite>main</cite>, <cite>temp</cite>, the name in <a class="reference external" href="https://sqlite.org/lang_attach.html">ATTACH</a></p>
</dd>
<dt>table name (str)</dt><dd><p>The table on which the update happened</p>
</dd>
<dt>rowid (int)</dt><dd><p>The affected row</p>
</dd>
</dl>
</div></blockquote>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="example.html#example-update-hook"><span class="std std-ref">Example</span></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/update_hook.html">sqlite3_update_hook</a></p>
</dd></dl>

<dl class="py method" id="index-45">
<dt class="sig sig-object py" id="apsw.Connection.set_wal_hook">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">set_wal_hook</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">callable</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference internal" href="#apsw.Connection" title="apsw.Connection"><span class="pre">Connection</span></a><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#str" title="(in Python v3.12)"><span class="pre">str</span></a><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#int" title="(in Python v3.12)"><span class="pre">int</span></a><span class="p"><span class="pre">]</span></span><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#int" title="(in Python v3.12)"><span class="pre">int</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></em><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="headerlink" href="#apsw.Connection.set_wal_hook" title="Link to this definition"></a></dt>
<dd><p><em>callable</em> will be called just after data is committed in <a class="reference internal" href="tips.html#wal"><span class="std std-ref">Write Ahead Logging</span></a>
mode.  It should return <em>SQLITE_OK</em> or an error code.  The
callback is called with 3 parameters:</p>
<blockquote>
<div><ul class="simple">
<li><p>The Connection</p></li>
<li><p>The database name.  <cite>main</cite>, <cite>temp</cite>, the name in <a class="reference external" href="https://sqlite.org/lang_attach.html">ATTACH</a></p></li>
<li><p>The number of pages in the wal log</p></li>
</ul>
</div></blockquote>
<p>You can pass in None in order to unregister an existing hook.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/wal_hook.html">sqlite3_wal_hook</a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.Connection.sqlite3_pointer">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">sqlite3_pointer</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/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></span><a class="headerlink" href="#apsw.Connection.sqlite3_pointer" title="Link to this definition"></a></dt>
<dd></dd></dl>

<p>Returns the underlying <a class="reference external" href="https://sqlite.org/c3ref/sqlite3.html">sqlite3 *</a> for the connection. This
method is useful if there are other C level libraries in the same
process and you want them to use the APSW connection handle. The value
is returned as a number using <a class="reference external" href="https://docs.python.org/3/c-api/long.html?highlight=pylong_fromvoidptr#c.PyLong_FromVoidPtr">PyLong_FromVoidPtr</a>
under the hood. You should also ensure that you increment the
reference count on the <a class="reference internal" href="#apsw.Connection" title="apsw.Connection"><code class="xref py py-class docutils literal notranslate"><span class="pre">Connection</span></code></a> for as long as the other
libraries are using the pointer.  It is also a very good idea to call
<a class="reference internal" href="apsw.html#apsw.sqlite_lib_version" title="apsw.sqlite_lib_version"><code class="xref py py-meth docutils literal notranslate"><span class="pre">sqlite_lib_version()</span></code></a> and ensure it is the same as the other
libraries.</p>
<dl class="py method" id="index-46">
<dt class="sig sig-object py" id="apsw.Connection.status">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">status</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">op</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#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">reset</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><span class="w"> </span><span class="o"><span class="pre">=</span></span><span class="w"> </span><span class="default_value"><span class="pre">False</span></span></em><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/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/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a><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#int" title="(in Python v3.12)"><span class="pre">int</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#apsw.Connection.status" title="Link to this definition"></a></dt>
<dd><p>Returns current and highwater measurements for the database.</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>op</strong> – A <a class="reference external" href="https://sqlite.org/c3ref/c_dbstatus_options.html">status parameter</a></p></li>
<li><p><strong>reset</strong> – If <em>True</em> then the highwater is set to the current value</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A tuple of current value and highwater value</p>
</dd>
</dl>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="apsw.html#apsw.status" title="apsw.status"><code class="xref py py-func docutils literal notranslate"><span class="pre">apsw.status()</span></code></a> which does the same for SQLite as a whole</p></li>
<li><p><a class="reference internal" href="example.html#example-status"><span class="std std-ref">Example</span></a></p></li>
</ul>
</div>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/db_status.html">sqlite3_db_status</a></p>
</dd></dl>

<dl class="py attribute" id="index-47">
<dt class="sig sig-object py" id="apsw.Connection.system_errno">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">system_errno</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#int" title="(in Python v3.12)"><span class="pre">int</span></a></em><a class="headerlink" href="#apsw.Connection.system_errno" title="Link to this definition"></a></dt>
<dd><p>The underlying system error code for the most recent I/O error.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/system_errno.html">sqlite3_system_errno</a></p>
</dd></dl>

<dl class="py method" id="index-48">
<dt class="sig sig-object py" id="apsw.Connection.table_exists">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">table_exists</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dbname</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 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></em>, <em class="sig-param"><span class="n"><span class="pre">table_name</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><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/functions.html#bool" title="(in Python v3.12)"><span class="pre">bool</span></a></span></span><a class="headerlink" href="#apsw.Connection.table_exists" title="Link to this definition"></a></dt>
<dd><p>Returns True if the named table exists, else False.</p>
<dl class="simple">
<dt><cite>dbname</cite> is <cite>main</cite>, <cite>temp</cite>, the name in <a class="reference external" href="https://sqlite.org/lang_attach.html">ATTACH</a>,</dt><dd><p>or None to search  all databases</p>
</dd>
</dl>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/table_column_metadata.html">sqlite3_table_column_metadata</a></p>
</dd></dl>

<dl class="py method" id="index-49">
<dt class="sig sig-object py" id="apsw.Connection.total_changes">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">total_changes</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/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></span><a class="headerlink" href="#apsw.Connection.total_changes" title="Link to this definition"></a></dt>
<dd><p>Returns the total number of database rows that have be modified,
inserted, or deleted since the database connection was opened.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/total_changes.html">sqlite3_total_changes64</a></p>
</dd></dl>

<dl class="py method" id="index-50">
<dt class="sig sig-object py" id="apsw.Connection.trace_v2">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">trace_v2</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">mask</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#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">callback</span></span><span class="p"><span class="pre">:</span></span><span class="w"> </span><span class="n"><span class="pre">Callable</span><span class="p"><span class="pre">[</span></span><span class="p"><span class="pre">[</span></span><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.12)"><span class="pre">dict</span></a><span class="p"><span class="pre">]</span></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 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><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="headerlink" href="#apsw.Connection.trace_v2" title="Link to this definition"></a></dt>
<dd><p>Registers a trace callback.  The callback is called with a dict of relevant values based
on the code.</p>
<table class="docutils align-default">
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Type</p></th>
<th class="head"><p>Explanation</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>code</p></td>
<td><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a></p></td>
<td><p>One of the <a class="reference external" href="https://www.sqlite.org/c3ref/c_trace.html">trace event codes</a></p></td>
</tr>
<tr class="row-odd"><td><p>connection</p></td>
<td><p><a class="reference internal" href="#apsw.Connection" title="apsw.Connection"><code class="xref py py-class docutils literal notranslate"><span class="pre">Connection</span></code></a></p></td>
<td><p>Connection this trace event belongs to</p></td>
</tr>
<tr class="row-even"><td><p>sql</p></td>
<td><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#str" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a></p></td>
<td><p>SQL text (except SQLITE_TRACE_CLOSE)</p></td>
</tr>
<tr class="row-odd"><td><p>profile</p></td>
<td><p><a class="reference external" href="https://docs.python.org/3/library/functions.html#int" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a></p></td>
<td><p>nanoseconds SQL took to execute (SQLITE_TRACE_PROFILE only)</p></td>
</tr>
<tr class="row-even"><td><p>stmt_status</p></td>
<td><p><a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.12)"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a></p></td>
<td><p>SQLITE_TRACE_PROFILE only: Keys are names from <a class="reference external" href="https://www.sqlite.org/c3ref/c_stmtstatus_counter.html">status parameters</a> - eg
<em>“SQLITE_STMTSTATUS_VM_STEP”</em> and corresponding integer values.
The counters are reset each time a statement
starts execution.</p></td>
</tr>
</tbody>
</table>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<ul class="simple">
<li><p><a class="reference internal" href="example.html#example-trace-v2"><span class="std std-ref">Example</span></a></p></li>
</ul>
</div>
<dl class="simple">
<dt>Calls:</dt><dd><ul class="simple">
<li><p><a class="reference external" href="https://sqlite.org/c3ref/trace_v2.html">sqlite3_trace_v2</a></p></li>
<li><p><a class="reference external" href="https://sqlite.org/c3ref/stmt_status.html">sqlite3_stmt_status</a></p></li>
</ul>
</dd>
</dl>
</dd></dl>

<dl class="py method" id="index-51">
<dt class="sig sig-object py" id="apsw.Connection.txn_state">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">txn_state</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">schema</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 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> <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/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></span><a class="headerlink" href="#apsw.Connection.txn_state" title="Link to this definition"></a></dt>
<dd><p>Returns the current transaction state of the database, or a specific schema
if provided.  <a class="reference internal" href="apsw.html#apsw.mapping_txn_state" title="apsw.mapping_txn_state"><code class="xref py py-attr docutils literal notranslate"><span class="pre">apsw.mapping_txn_state</span></code></a> contains the values returned.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/txn_state.html">sqlite3_txn_state</a></p>
</dd></dl>

<dl class="py method">
<dt class="sig sig-object py" id="apsw.Connection.vfsname">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">vfsname</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dbname</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><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/stdtypes.html#str" title="(in Python v3.12)"><span class="pre">str</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><a class="headerlink" href="#apsw.Connection.vfsname" title="Link to this definition"></a></dt>
<dd></dd></dl>

<p>Issues the <a class="reference external" href="https://sqlite.org/c3ref/c_fcntl_begin_atomic_write.html#sqlitefcntlvfsname">SQLITE_FCNTL_VFSNAME</a>
file control against the named database (<cite>main</cite>, <cite>temp</cite>, attached
name).</p>
<p>This is useful to see which VFS is in use, and if inheritance is used
then <code class="docutils literal notranslate"><span class="pre">/</span></code> will separate the names.  If you have a <a class="reference internal" href="vfs.html#apsw.VFSFile" title="apsw.VFSFile"><code class="xref py py-class docutils literal notranslate"><span class="pre">VFSFile</span></code></a> in
use then its fully qualified class name will also be included.</p>
<p>If <code class="docutils literal notranslate"><span class="pre">SQLITE_FCNTL_VFSNAME</span></code> is not implemented, <code class="docutils literal notranslate"><span class="pre">dbname</span></code> is not a
database name, or an error occurred then <code class="docutils literal notranslate"><span class="pre">None</span></code> is returned.</p>
<dl class="py method" id="index-52">
<dt class="sig sig-object py" id="apsw.Connection.vtab_config">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">vtab_config</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">op</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#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em>, <em class="sig-param"><span class="n"><span class="pre">val</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#int" title="(in Python v3.12)"><span class="pre">int</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">0</span></span></em><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="headerlink" href="#apsw.Connection.vtab_config" title="Link to this definition"></a></dt>
<dd><p>Callable during virtual table <a class="reference internal" href="vtable.html#apsw.VTModule.Connect" title="apsw.VTModule.Connect"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Connect()</span></code></a>/<a class="reference internal" href="vtable.html#apsw.VTModule.Create" title="apsw.VTModule.Create"><code class="xref py py-meth docutils literal notranslate"><span class="pre">Create()</span></code></a>.</p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/vtab_config.html">sqlite3_vtab_config</a></p>
</dd></dl>

<dl class="py method" id="index-53">
<dt class="sig sig-object py" id="apsw.Connection.vtab_on_conflict">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">vtab_on_conflict</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/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></span><a class="headerlink" href="#apsw.Connection.vtab_on_conflict" title="Link to this definition"></a></dt>
<dd><p>Callable during virtual table <a class="reference internal" href="vtable.html#apsw.VTTable.UpdateInsertRow" title="apsw.VTTable.UpdateInsertRow"><code class="xref py py-meth docutils literal notranslate"><span class="pre">insert</span></code></a> or
<a class="reference internal" href="vtable.html#apsw.VTTable.UpdateChangeRow" title="apsw.VTTable.UpdateChangeRow"><code class="xref py py-meth docutils literal notranslate"><span class="pre">update</span></code></a></p>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/vtab_on_conflict.html">sqlite3_vtab_on_conflict</a></p>
</dd></dl>

<dl class="py method" id="index-54">
<dt class="sig sig-object py" id="apsw.Connection.wal_autocheckpoint">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">wal_autocheckpoint</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</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#int" title="(in Python v3.12)"><span class="pre">int</span></a></span></em><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="headerlink" href="#apsw.Connection.wal_autocheckpoint" title="Link to this definition"></a></dt>
<dd><p>Sets how often the <a class="reference internal" href="tips.html#wal"><span class="std std-ref">Write Ahead Logging</span></a> checkpointing is run.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><p><strong>n</strong> – A number representing the checkpointing interval or
zero/negative to disable auto checkpointing.</p>
</dd>
</dl>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/wal_autocheckpoint.html">sqlite3_wal_autocheckpoint</a></p>
</dd></dl>

<dl class="py method" id="index-55">
<dt class="sig sig-object py" id="apsw.Connection.wal_checkpoint">
<span class="sig-prename descclassname"><span class="pre">Connection.</span></span><span class="sig-name descname"><span class="pre">wal_checkpoint</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">dbname</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 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">mode</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#int" title="(in Python v3.12)"><span class="pre">int</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">apsw.SQLITE_CHECKPOINT_PASSIVE</span></span></em><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/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/functions.html#int" title="(in Python v3.12)"><span class="pre">int</span></a><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#int" title="(in Python v3.12)"><span class="pre">int</span></a><span class="p"><span class="pre">]</span></span></span></span><a class="headerlink" href="#apsw.Connection.wal_checkpoint" title="Link to this definition"></a></dt>
<dd><p>Does a WAL checkpoint.  Has no effect if the database(s) are not in WAL mode.</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>dbname</strong> – The name of the database or all databases if None</p></li>
<li><p><strong>mode</strong> – One of the <a class="reference external" href="https://sqlite.org/c3ref/wal_checkpoint_v2.html">checkpoint modes</a>.</p></li>
</ul>
</dd>
<dt class="field-even">Returns<span class="colon">:</span></dt>
<dd class="field-even"><p>A tuple of the size of the WAL log in frames and the
number of frames checkpointed as described in the
<a class="reference external" href="https://sqlite.org/c3ref/wal_checkpoint_v2.html">documentation</a>.</p>
</dd>
</dl>
<p>Calls: <a class="reference external" href="https://sqlite.org/c3ref/wal_checkpoint_v2.html">sqlite3_wal_checkpoint_v2</a></p>
</dd></dl>

</section>
</section>


           </div>
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="apsw.html" class="btn btn-neutral float-left" title="APSW Module" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="cursor.html" class="btn btn-neutral float-right" title="Cursors (executing SQL)" 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>