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
U
¸ý°déã@sôUdZddlmZddlZddlZddlZddlmZddlmZddlmZddlm    Z    ddlm
Z
dd    lm Z dd
lm Z dd lm Z dd lmZdd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddl m!Z!ddl m"Z"dd l m#Z#dd!l mZdd"l$m%Z%dd!l$mZ&ej'rdd#l m(Z(dd$l m)Z)dd%lm*Z*dd&lm+Z+dd'lm,Z,dd(lm-Z-dd)lm.Z.dd*lm/Z/dd+lm0Z0dd,lm1Z1dd-lm2Z2dd.lm3Z3dd/lm4Z4dd0lm5Z5dd1l6m7Z7dd2l8m9Z9dd3l:m;Z;dd4l#m<Z<dd5l=m>Z>dd6l=m?Z?dd7l=m@Z@dd8l$mAZAdd9lBmCZCdd:lDmEZEdd;lFmGZGdd<lFmHZHdd=lFmIZIdd>lJmKZKdd?lLmMZMdd@lLmNZNddAlLmOZOddBlPmQZQedCedDZRejSZTdEeUdF<ejSZVdGeUdH<GdIdJ„dJee"jWdKƒZXGdLdM„dMeƒZYGdNdO„dOeƒZZGdPdQ„dQeZƒZ[GdRdS„dSeZƒZ\GdTdU„dUe[ƒZ]GdVdW„dWee#j^e"jWdKƒZ_GdXdY„dYe#j^ƒZ`GdZd[„d[e`e_ƒZaeae__bdS)\zBDefines :class:`_engine.Connection` and :class:`_engine.Engine`.
 
é)Ú annotationsN)ÚAny)ÚCallable)Úcast)ÚIterable)ÚIterator)ÚList)ÚMapping)ÚNoReturn)ÚOptional)Úoverload)ÚTuple)ÚType)ÚTypeVar)ÚUnioné)Ú
BindTyping)ÚConnectionEventsTarget)Ú DBAPICursor)ÚExceptionContext)Ú ExecuteStyle)ÚExecutionContext)ÚIsolationLevel)Ú_distill_params_20)Ú_distill_raw_params)ÚTransactionalContexté)Úexc)Ú
inspection)Úlog)Úutil)Úcompiler)Ú CursorResult)Ú ScalarResult)Ú_AnyExecuteParams)Ú_AnyMultiExecuteParams)Ú_CoreAnyExecuteParams)Ú_CoreMultiExecuteParams)Ú_CoreSingleExecuteParams)Ú_DBAPIAnyExecuteParams)Ú_DBAPISingleExecuteParams)Ú_ExecuteOptions)ÚCompiledCacheType)ÚCoreExecuteOptionsParameter)ÚDialect)ÚSchemaTranslateMapType)Ú    Inspector)ÚURL)Ú
dispatcher)Ú _EchoFlagType)Ú_ConnectionFairy)ÚPool)ÚPoolProxiedConnection)Ú
Executable)Ú    _InfoType)ÚCompiled)ÚExecutableDDLElement)Ú SchemaDropper)ÚSchemaGenerator)ÚFunctionElement)ÚDefaultGenerator)Ú HasSchemaAttr)Ú
SchemaItem)ÚTypedReturnsRowsÚ_T)Úboundr+Ú_EMPTY_EXECUTION_OPTSzMapping[str, Any]Ú
NO_OPTIONSc@s"eZdZUdZded<dZdZded<dZd    ed
<d ed <d ed<ded<dôdd    ddddœdd„Ze    j
ddœdd„ƒZ dddddœdd „Z dddddœd!d"„Z ed#dœd$d%„ƒZd&d'd(œd)d*„Zddœd+d,„Zddddd-œd.d/„Zed0d0d0ddd0d0d0d0d1œ    d2dd3ddd4d4d4d#ddd5œ d6d7„ƒZeddd8œd9d7„ƒZddd8œd:d7„Zd dœd;d<„Zeddœd=d>„ƒZeddœd?d@„ƒZeddœdAdB„ƒZedCdœdDdE„ƒZd3dœdFdG„ZedHdœdIdJ„ƒZdKdœdLdM„ZdCdœdNdO„ZedPdœdQdR„ƒZdõdSddTœdUdV„ZddœdWdX„Z ddœdYdZ„Z!d[dœd\d]„Z"d^dœd_d`„Z#dödadbdcœddde„Z$ddœdfdg„Z%ddœdhdi„Z&djdœdkdl„Z'd÷ddddmœdndo„Z(døddddmœdpdq„Z)ddœdrds„Z*ddœdtdu„Z+ddœdvdw„Z,d[dœdxdy„Z-d^dœdzd{„Z.d dœd|d}„Z/ddœd~d„Z0d[dd€œdd‚„Z1ddœdƒd„„Z2ddœd…d†„Z3dùd'dd‡œdˆd‰„Z4ddd‡œdŠd‹„Z5ddd‡œdŒd„Z6dbdd€œdŽd„Z7dddcœdd‘„Z8dddd’œd“d”„Z9dddd’œd•d–„Z:ddœd—d˜„Z;edúdd™œdšd›dœddžœdŸd „ƒZ<edûdd™œd¡d›dœddžœd¢d „ƒZ<düdd™œd¡d›dœddžœd£d „Z<edýdd™œdšd¤dœd¥džœd¦d§„ƒZ=edþdd™œd¡d¤dœd¨džœd©d§„ƒZ=dÿdd™œd¡d¤dœd¨džœdªd§„Z=eddd™œd«d¤dœd¬džœd­d®„ƒZ>eddd™œd¡d¤dœd¯džœd°d®„ƒZ>ddd™œd¡d¤dœd¯džœd±d®„Z>d²d³d´d¯dµœd¶d·„Z?d¸d³d´dd¹œdºd»„Z@d¼d³d´d¯d½œd¾d¿„ZAdd³d dÀdÁœdÂdÄZBd¡d³d´d¯dĜdÅdƄZCeDfdÇd³d´d¯dȜdÉdʄZEdddËdœd¯džœdÌd̈́ZFdÎdÏdÐdÑd ddd¯dҜdÓdԄZGdÎdÕdÐdÑd¯d֜d×d؄ZHdÎdÕd¯dٜdÚdۄZIddÜddÝdÞddߜdàdá„ZJdÜddâœdãdä„ZKdZLdZMddåd'dædçdÞddKdèœdédê„ZNeOddådÎdëddddKdìœdídZPdïdðdddñœdòdó„ZQdS(Ú
Connectiona:Provides high-level functionality for a wrapped DB-API connection.
 
    The :class:`_engine.Connection` object is procured by calling the
    :meth:`_engine.Engine.connect` method of the :class:`_engine.Engine`
    object, and provides services for execution of SQL statements as well
    as transaction control.
 
    The Connection object is **not** thread-safe. While a Connection can be
    shared among threads using properly synchronized access, it is still
    possible that the underlying DBAPI connection may not support shared
    access between threads. Check the DBAPI documentation for details.
 
    The Connection object represents a single DBAPI connection checked out
    from the connection pool. In this state, the connection pool has no
    affect upon the connection, including its expiration or timeout state.
    For the connection pool to properly manage connections, connections
    should be returned to the connection pool (i.e. ``connection.close()``)
    whenever the connection is not in use.
 
    .. index::
      single: thread safety; Connection
 
    ú"dispatcher[ConnectionEventsTarget]Údispatchzsqlalchemy.engine.ConnectionNzOptional[TransactionalContext]Ú_trans_context_managerFzOptional[PoolProxiedConnection]Ú_dbapi_connectionr+Ú_execution_optionszOptional[RootTransaction]Ú _transactionzOptional[NestedTransaction]Ú_nested_transactionTÚEnginezOptional[bool]Úbool)ÚengineÚ
connectionÚ _has_eventsÚ_allow_revalidateÚ_allow_autobeginc
Csê||_|j|_}|dkrbz| ¡|_Wqh|jjk
r^}zt |||¡‚W5d}~XYqhXn||_d|_|_    d|_
d|_ ||_ ||_ |j ¡|_|dkr°|j |j¡|_|pÀ|dkoÀ|j|_|j|_|jsÚ|jjræ|j |¡dS)zConstruct a new Connection.NrF)rPÚdialectÚraw_connectionrJÚ loaded_dbapiÚErrorrFÚ$_handle_dbapi_exception_noconnectionrLrMÚ_Connection__savepoint_seqÚ_Connection__in_beginÚ_Connection__can_reconnectrTÚ_should_log_infoÚ_echorHÚ_joinrRrKZengine_connect)ÚselfrPrQrRrSrTrUÚerr©rbúMd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/engine/base.pyÚ__init__ƒs6     ÿ   ÿzConnection.__init__r©Úreturncs(d|jkr |jd‰‡fdd„SdSdS)NÚ logging_tokencs dˆ|fS)Nz[%s] %srb)Úmsg©ÚtokenrbrcÚ<lambda>´óz/Connection._message_formatter.<locals>.<lambda>©rK©r`rbrircÚ_message_formatter°s
 
 zConnection._message_formatterÚstrÚNone)ÚmessageÚargÚkwrfcOs@|j}|r||ƒ}tjr&dtj|d<|jjj|f|ž|ŽdS©NrÚ
stacklevel)rorÚ
STACKLEVELÚSTACKLEVEL_OFFSETrPÚloggerÚinfo©r`rrrsrtÚfmtrbrbrcÚ    _log_info¸s zConnection._log_infocOs@|j}|r||ƒ}tjr&dtj|d<|jjj|f|ž|ŽdSru)rorrwrxrPryÚdebugr{rbrbrcÚ
_log_debugÃs zConnection._log_debugú Optional[SchemaTranslateMapType]cCs|j dd¡S)NÚschema_translate_map)rKÚgetrnrbrbrcÚ_schema_translate_mapÎsz Connection._schema_translate_mapr?ú Optional[str])ÚobjrfcCs6|j}|j dd¡}|r.||kr.|jr.||S|SdS)ztReturn the schema name for the given schema item taking into
        account current schema translate map.
 
        rN)ZschemarKr‚Z_use_schema_map)r`r…ÚnamerrbrbrcÚschema_for_objectÒs þÿþýzConnection.schema_for_objectcCs|S©NrbrnrbrbrcÚ    __enter__æszConnection.__enter__)Útype_ÚvalueÚ    tracebackrfcCs | ¡dSrˆ)Úclose)r`rŠr‹rŒrbrbrcÚ__exit__észConnection.__exit__.)    Úcompiled_cachergÚisolation_levelÚ no_parametersÚstream_resultsÚmax_row_bufferÚ    yield_perÚinsertmanyvalues_page_sizerúOptional[CompiledCacheType]rÚint) rrgrr‘r’r“r”r•rÚoptrfc     KsdSrˆrb) r`rrgrr‘r’r“r”r•rr˜rbrbrcÚexecution_optionsìszConnection.execution_options©r˜rfcKsdSrˆrb©r`r˜rbrbrcr™ýscKs<|js|jjr|j ||¡|j |¡|_|j ||¡|S)a3.Set non-SQL options for the connection which take effect
        during execution.
 
        This method modifies this :class:`_engine.Connection` **in-place**;
        the return value is the same :class:`_engine.Connection` object
        upon which the method is called.   Note that this is in contrast
        to the behavior of the ``execution_options`` methods on other
        objects such as :meth:`_engine.Engine.execution_options` and
        :meth:`_sql.Executable.execution_options`.  The rationale is that many
        such execution options necessarily modify the state of the base
        DBAPI connection in any case so there is no feasible means of
        keeping the effect of such an option localized to a "sub" connection.
 
        .. versionchanged:: 2.0  The :meth:`_engine.Connection.execution_options`
           method, in contrast to other objects with this method, modifies
           the connection in-place without creating copy of it.
 
        As discussed elsewhere, the :meth:`_engine.Connection.execution_options`
        method accepts any arbitrary parameters including user defined names.
        All parameters given are consumable in a number of ways including
        by using the :meth:`_engine.Connection.get_execution_options` method.
        See the examples at :meth:`_sql.Executable.execution_options`
        and :meth:`_engine.Engine.execution_options`.
 
        The keywords that are currently recognized by SQLAlchemy itself
        include all those listed under :meth:`.Executable.execution_options`,
        as well as others that are specific to :class:`_engine.Connection`.
 
        :param compiled_cache: Available on: :class:`_engine.Connection`,
          :class:`_engine.Engine`.
 
          A dictionary where :class:`.Compiled` objects
          will be cached when the :class:`_engine.Connection`
          compiles a clause
          expression into a :class:`.Compiled` object.  This dictionary will
          supersede the statement cache that may be configured on the
          :class:`_engine.Engine` itself.   If set to None, caching
          is disabled, even if the engine has a configured cache size.
 
          Note that the ORM makes use of its own "compiled" caches for
          some operations, including flush operations.  The caching
          used by the ORM internally supersedes a cache dictionary
          specified here.
 
        :param logging_token: Available on: :class:`_engine.Connection`,
          :class:`_engine.Engine`, :class:`_sql.Executable`.
 
          Adds the specified string token surrounded by brackets in log
          messages logged by the connection, i.e. the logging that's enabled
          either via the :paramref:`_sa.create_engine.echo` flag or via the
          ``logging.getLogger("sqlalchemy.engine")`` logger. This allows a
          per-connection or per-sub-engine token to be available which is
          useful for debugging concurrent connection scenarios.
 
          .. versionadded:: 1.4.0b2
 
          .. seealso::
 
            :ref:`dbengine_logging_tokens` - usage example
 
            :paramref:`_sa.create_engine.logging_name` - adds a name to the
            name used by the Python logger object itself.
 
        :param isolation_level: Available on: :class:`_engine.Connection`,
          :class:`_engine.Engine`.
 
          Set the transaction isolation level for the lifespan of this
          :class:`_engine.Connection` object.
          Valid values include those string
          values accepted by the :paramref:`_sa.create_engine.isolation_level`
          parameter passed to :func:`_sa.create_engine`.  These levels are
          semi-database specific; see individual dialect documentation for
          valid levels.
 
          The isolation level option applies the isolation level by emitting
          statements on the DBAPI connection, and **necessarily affects the
          original Connection object overall**. The isolation level will remain
          at the given setting until explicitly changed, or when the DBAPI
          connection itself is :term:`released` to the connection pool, i.e. the
          :meth:`_engine.Connection.close` method is called, at which time an
          event handler will emit additional statements on the DBAPI connection
          in order to revert the isolation level change.
 
          .. note:: The ``isolation_level`` execution option may only be
             established before the :meth:`_engine.Connection.begin` method is
             called, as well as before any SQL statements are emitted which
             would otherwise trigger "autobegin", or directly after a call to
             :meth:`_engine.Connection.commit` or
             :meth:`_engine.Connection.rollback`. A database cannot change the
             isolation level on a transaction in progress.
 
          .. note:: The ``isolation_level`` execution option is implicitly
             reset if the :class:`_engine.Connection` is invalidated, e.g. via
             the :meth:`_engine.Connection.invalidate` method, or if a
             disconnection error occurs. The new connection produced after the
             invalidation will **not** have the selected isolation level
             re-applied to it automatically.
 
          .. seealso::
 
                :ref:`dbapi_autocommit`
 
                :meth:`_engine.Connection.get_isolation_level`
                - view current actual level
 
        :param no_parameters: Available on: :class:`_engine.Connection`,
          :class:`_sql.Executable`.
 
          When ``True``, if the final parameter
          list or dictionary is totally empty, will invoke the
          statement on the cursor as ``cursor.execute(statement)``,
          not passing the parameter collection at all.
          Some DBAPIs such as psycopg2 and mysql-python consider
          percent signs as significant only when parameters are
          present; this option allows code to generate SQL
          containing percent signs (and possibly other characters)
          that is neutral regarding whether it's executed by the DBAPI
          or piped into a script that's later invoked by
          command line tools.
 
        :param stream_results: Available on: :class:`_engine.Connection`,
          :class:`_sql.Executable`.
 
          Indicate to the dialect that results should be
          "streamed" and not pre-buffered, if possible.  For backends
          such as PostgreSQL, MySQL and MariaDB, this indicates the use of
          a "server side cursor" as opposed to a client side cursor.
          Other backends such as that of Oracle may already use server
          side cursors by default.
 
          The usage of
          :paramref:`_engine.Connection.execution_options.stream_results` is
          usually combined with setting a fixed number of rows to to be fetched
          in batches, to allow for efficient iteration of database rows while
          at the same time not loading all result rows into memory at once;
          this can be configured on a :class:`_engine.Result` object using the
          :meth:`_engine.Result.yield_per` method, after execution has
          returned a new :class:`_engine.Result`.   If
          :meth:`_engine.Result.yield_per` is not used,
          the :paramref:`_engine.Connection.execution_options.stream_results`
          mode of operation will instead use a dynamically sized buffer
          which buffers sets of rows at a time, growing on each batch
          based on a fixed growth size up until a limit which may
          be configured using the
          :paramref:`_engine.Connection.execution_options.max_row_buffer`
          parameter.
 
          When using the ORM to fetch ORM mapped objects from a result,
          :meth:`_engine.Result.yield_per` should always be used with
          :paramref:`_engine.Connection.execution_options.stream_results`,
          so that the ORM does not fetch all rows into new ORM objects at once.
 
          For typical use, the
          :paramref:`_engine.Connection.execution_options.yield_per` execution
          option should be preferred, which sets up both
          :paramref:`_engine.Connection.execution_options.stream_results` and
          :meth:`_engine.Result.yield_per` at once. This option is supported
          both at a core level by :class:`_engine.Connection` as well as by the
          ORM :class:`_engine.Session`; the latter is described at
          :ref:`orm_queryguide_yield_per`.
 
          .. seealso::
 
            :ref:`engine_stream_results` - background on
            :paramref:`_engine.Connection.execution_options.stream_results`
 
            :paramref:`_engine.Connection.execution_options.max_row_buffer`
 
            :paramref:`_engine.Connection.execution_options.yield_per`
 
            :ref:`orm_queryguide_yield_per` - in the :ref:`queryguide_toplevel`
            describing the ORM version of ``yield_per``
 
        :param max_row_buffer: Available on: :class:`_engine.Connection`,
          :class:`_sql.Executable`.  Sets a maximum
          buffer size to use when the
          :paramref:`_engine.Connection.execution_options.stream_results`
          execution option is used on a backend that supports server side
          cursors.  The default value if not specified is 1000.
 
          .. seealso::
 
            :paramref:`_engine.Connection.execution_options.stream_results`
 
            :ref:`engine_stream_results`
 
 
        :param yield_per: Available on: :class:`_engine.Connection`,
          :class:`_sql.Executable`.  Integer value applied which will
          set the :paramref:`_engine.Connection.execution_options.stream_results`
          execution option and invoke :meth:`_engine.Result.yield_per`
          automatically at once.  Allows equivalent functionality as
          is present when using this parameter with the ORM.
 
          .. versionadded:: 1.4.40
 
          .. seealso::
 
            :ref:`engine_stream_results` - background and examples
            on using server side cursors with Core.
 
            :ref:`orm_queryguide_yield_per` - in the :ref:`queryguide_toplevel`
            describing the ORM version of ``yield_per``
 
        :param insertmanyvalues_page_size: Available on: :class:`_engine.Connection`,
            :class:`_engine.Engine`. Number of rows to format into an
            INSERT statement when the statement uses "insertmanyvalues" mode,
            which is a paged form of bulk insert that is used for many backends
            when using :term:`executemany` execution typically in conjunction
            with RETURNING. Defaults to 1000. May also be modified on a
            per-engine basis using the
            :paramref:`_sa.create_engine.insertmanyvalues_page_size` parameter.
 
            .. versionadded:: 2.0
 
            .. seealso::
 
                :ref:`engine_insertmanyvalues`
 
        :param schema_translate_map: Available on: :class:`_engine.Connection`,
          :class:`_engine.Engine`, :class:`_sql.Executable`.
 
          A dictionary mapping schema names to schema names, that will be
          applied to the :paramref:`_schema.Table.schema` element of each
          :class:`_schema.Table`
          encountered when SQL or DDL expression elements
          are compiled into strings; the resulting schema name will be
          converted based on presence in the map of the original name.
 
          .. seealso::
 
            :ref:`schema_translating`
 
        .. seealso::
 
            :meth:`_engine.Engine.execution_options`
 
            :meth:`.Executable.execution_options`
 
            :meth:`_engine.Connection.get_execution_options`
 
            :ref:`orm_queryguide_execution_options` - documentation on all
            ORM-specific execution options
 
        )rRrPrHZ set_connection_execution_optionsrKÚunionrUr›rbrbrcr™s wcCs|jS)z¸Get the non-SQL options which will take effect during execution.
 
        .. versionadded:: 1.3
 
        .. seealso::
 
            :meth:`_engine.Connection.execution_options`
        rmrnrbrbrcÚget_execution_optionsýs    z Connection.get_execution_optionscCs|j}|dk    o|jSrˆ)rJÚis_valid©r`Úpool_proxied_connectionrbrbrcÚ)_still_open_and_dbapi_connection_is_validsþz4Connection._still_open_and_dbapi_connection_is_validcCs|jdko|j S)z)Return True if this connection is closed.N©rJr\rnrbrbrcÚclosedszConnection.closedcCs|j}|dko|jS)zªReturn True if this connection was invalidated.
 
        This does not indicate whether or not the connection was
        invalidated at the pool level, however
 
        Nr¢rŸrbrbrcÚ invalidatedszConnection.invalidatedr6c
Csr|jdkrhz
| ¡WStjtjfk
r2‚Yqntk
rd}z| |dddd¡W5d}~XYqnXn|jSdS)aVThe underlying DB-API connection managed by this Connection.
 
        This is a SQLAlchemy connection-pool proxied connection
        which then has the attribute
        :attr:`_pool._ConnectionFairy.dbapi_connection` that refers to the
        actual driver connection.
 
        .. seealso::
 
 
            :ref:`dbapi_connections`
 
        N)rJÚ_revalidate_connectionrÚPendingRollbackErrorÚResourceClosedErrorÚ BaseExceptionÚ_handle_dbapi_exception©r`ÚerbrbrcrQ+s
 
&zConnection.connectionc
Cs\|jj}|dk    st‚z|j |¡WStk
rV}z| |dddd¡W5d}~XYnXdS)aÖReturn the current **actual** isolation level that's present on
        the database within the scope of this connection.
 
        This attribute will perform a live SQL operation against the database
        in order to procure the current isolation level, so the value returned
        is the actual level on the underlying DBAPI connection regardless of
        how this state was set. This will be one of the four actual isolation
        modes ``READ UNCOMMITTED``, ``READ COMMITTED``, ``REPEATABLE READ``,
        ``SERIALIZABLE``. It will **not** include the ``AUTOCOMMIT`` isolation
        level setting. Third party dialects may also feature additional
        isolation level settings.
 
        .. note::  This method **will not report** on the ``AUTOCOMMIT``
          isolation level, which is a separate :term:`dbapi` setting that's
          independent of **actual** isolation level.  When ``AUTOCOMMIT`` is
          in use, the database connection still has a "traditional" isolation
          mode in effect, that is typically one of the four values
          ``READ UNCOMMITTED``, ``READ COMMITTED``, ``REPEATABLE READ``,
          ``SERIALIZABLE``.
 
        Compare to the :attr:`_engine.Connection.default_isolation_level`
        accessor which returns the isolation level that is present on the
        database at initial connection time.
 
        .. seealso::
 
            :attr:`_engine.Connection.default_isolation_level`
            - view default level
 
            :paramref:`_sa.create_engine.isolation_level`
            - set per :class:`_engine.Engine` isolation level
 
            :paramref:`.Connection.execution_options.isolation_level`
            - set per :class:`_engine.Connection` isolation level
 
        N)rQÚdbapi_connectionÚAssertionErrorrUÚget_isolation_levelr¨r©)r`r¬r«rbrbrcr®Es % zConnection.get_isolation_levelzOptional[IsolationLevel]cCs|jjS)aöThe initial-connection time isolation level associated with the
        :class:`_engine.Dialect` in use.
 
        This value is independent of the
        :paramref:`.Connection.execution_options.isolation_level` and
        :paramref:`.Engine.execution_options.isolation_level` execution
        options, and is determined by the :class:`_engine.Dialect` when the
        first connection is created, by performing a SQL query against the
        database for the current isolation level before any additional commands
        have been emitted.
 
        Calling this accessor does not invoke any new SQL queries.
 
        .. seealso::
 
            :meth:`_engine.Connection.get_isolation_level`
            - view current actual isolation level
 
            :paramref:`_sa.create_engine.isolation_level`
            - set per :class:`_engine.Engine` isolation level
 
            :paramref:`.Connection.execution_options.isolation_level`
            - set per :class:`_engine.Connection` isolation level
 
        )rUÚdefault_isolation_levelrnrbrbrcr¯qsz"Connection.default_isolation_levelr
cCs$tjd|jdk    rdnddd‚dS)NzfCan't reconnect until invalid %stransaction is rolled back.  Please rollback() fully before proceedingz
savepoint ÚZ8s2b)Úcode)rr¦rMrnrbrbrcÚ_invalid_transactionŽs þüzConnection._invalid_transactioncCs>|jr0|jr0|jdk    r| ¡|j ¡|_|jSt d¡‚dS)NúThis Connection is closed)    r\r¤rLr²rPrVrJrr§rnrbrbrcr¥–s  
 z!Connection._revalidate_connectionr8cCs|jjS)a›Info dictionary associated with the underlying DBAPI connection
        referred to by this :class:`_engine.Connection`, allowing user-defined
        data to be associated with the connection.
 
        The data here will follow along with the DBAPI connection including
        after it is returned to the connection pool and used again
        in subsequent instances of :class:`_engine.Connection`.
 
        )rQrzrnrbrbrcrzžs zConnection.infozOptional[BaseException])Ú    exceptionrfcCsF|jr
dS|jrt d¡‚|jr<|j}|dk    s2t‚| |¡d|_dS)aåInvalidate the underlying DBAPI connection associated with
        this :class:`_engine.Connection`.
 
        An attempt will be made to close the underlying DBAPI connection
        immediately; however if this operation fails, the error is logged
        but not raised.  The connection is then discarded whether or not
        close() succeeded.
 
        Upon the next use (where "use" typically means using the
        :meth:`_engine.Connection.execute` method or similar),
        this :class:`_engine.Connection` will attempt to
        procure a new DBAPI connection using the services of the
        :class:`_pool.Pool` as a source of connectivity (e.g.
        a "reconnection").
 
        If a transaction was in progress (e.g. the
        :meth:`_engine.Connection.begin` method has been called) when
        :meth:`_engine.Connection.invalidate` method is called, at the DBAPI
        level all state associated with this transaction is lost, as
        the DBAPI connection is closed.  The :class:`_engine.Connection`
        will not allow a reconnection to proceed until the
        :class:`.Transaction` object is ended, by calling the
        :meth:`.Transaction.rollback` method; until that point, any attempt at
        continuing to use the :class:`_engine.Connection` will raise an
        :class:`~sqlalchemy.exc.InvalidRequestError`.
        This is to prevent applications from accidentally
        continuing an ongoing transactional operations despite the
        fact that the transaction has been lost due to an
        invalidation.
 
        The :meth:`_engine.Connection.invalidate` method,
        just like auto-invalidation,
        will at the connection pool level invoke the
        :meth:`_events.PoolEvents.invalidate` event.
 
        :param exception: an optional ``Exception`` instance that's the
         reason for the invalidation.  is passed along to event handlers
         and logging functions.
 
        .. seealso::
 
            :ref:`pool_connection_invalidation`
 
        Nr³)r¤r£rr§r¡rJr­Ú
invalidate)r`r´r rbrbrcrµ¬s.
 
zConnection.invalidatecCs4|jrt d¡‚|j}|dkr(t d¡‚| ¡dS)a2Detach the underlying DB-API connection from its connection pool.
 
        E.g.::
 
            with engine.connect() as conn:
                conn.detach()
                conn.execute(text("SET search_path TO schema1, schema2"))
 
                # work with connection
 
            # connection is fully closed (since we used "with:", can
            # also call .close())
 
        This :class:`_engine.Connection` instance will remain usable.
        When closed
        (or exited from a context manager context as above),
        the DB-API connection will be literally closed and not
        returned to its originating pool.
 
        This method can be used to insulate the rest of an application
        from a modified state on a connection (such as a transaction
        isolation level or similar).
 
        r³Nz&Can't detach an invalidated Connection)r£rr§rJÚInvalidRequestErrorÚdetachrŸrbrbrcr·çs
ÿzConnection.detachcCs|jr|js| ¡dSrˆ)rTr[ÚbeginrnrbrbrcÚ
_autobegin s zConnection._autobeginÚRootTransactioncCs(|jdkrt|ƒ|_|jSt d¡‚dS)a¥    Begin a transaction prior to autobegin occurring.
 
        E.g.::
 
            with engine.connect() as conn:
                with conn.begin() as trans:
                    conn.execute(table.insert(), {"username": "sandy"})
 
 
        The returned object is an instance of :class:`_engine.RootTransaction`.
        This object represents the "scope" of the transaction,
        which completes when either the :meth:`_engine.Transaction.rollback`
        or :meth:`_engine.Transaction.commit` method is called; the object
        also works as a context manager as illustrated above.
 
        The :meth:`_engine.Connection.begin` method begins a
        transaction that normally will be begun in any case when the connection
        is first used to execute a statement.  The reason this method might be
        used would be to invoke the :meth:`_events.ConnectionEvents.begin`
        event at a specific time, or to organize code within the scope of a
        connection checkout in terms of context managed blocks, such as::
 
            with engine.connect() as conn:
                with conn.begin():
                    conn.execute(...)
                    conn.execute(...)
 
                with conn.begin():
                    conn.execute(...)
                    conn.execute(...)
 
        The above code is not  fundamentally any different in its behavior than
        the following code  which does not use
        :meth:`_engine.Connection.begin`; the below style is referred towards
        as "commit as you go" style::
 
            with engine.connect() as conn:
                conn.execute(...)
                conn.execute(...)
                conn.commit()
 
                conn.execute(...)
                conn.execute(...)
                conn.commit()
 
        From a database point of view, the :meth:`_engine.Connection.begin`
        method does not emit any SQL or change the state of the underlying
        DBAPI connection in any way; the Python DBAPI does not have any
        concept of explicit transaction begin.
 
        .. seealso::
 
            :ref:`tutorial_working_with_transactions` - in the
            :ref:`unified_tutorial`
 
            :meth:`_engine.Connection.begin_nested` - use a SAVEPOINT
 
            :meth:`_engine.Connection.begin_twophase` -
            use a two phase /XID transaction
 
            :meth:`_engine.Engine.begin` - context manager available from
            :class:`_engine.Engine`
 
        NzªThis connection has already initialized a SQLAlchemy Transaction() object via begin() or autobegin; can't call begin() here unless rollback() or commit() is called first.)rLrºrr¶rnrbrbrcr¸s A
 
ÿzConnection.beginÚNestedTransactioncCs|jdkr| ¡t|ƒS)aâ Begin a nested transaction (i.e. SAVEPOINT) and return a transaction
        handle that controls the scope of the SAVEPOINT.
 
        E.g.::
 
            with engine.begin() as connection:
                with connection.begin_nested():
                    connection.execute(table.insert(), {"username": "sandy"})
 
        The returned object is an instance of
        :class:`_engine.NestedTransaction`, which includes transactional
        methods :meth:`_engine.NestedTransaction.commit` and
        :meth:`_engine.NestedTransaction.rollback`; for a nested transaction,
        these methods correspond to the operations "RELEASE SAVEPOINT <name>"
        and "ROLLBACK TO SAVEPOINT <name>". The name of the savepoint is local
        to the :class:`_engine.NestedTransaction` object and is generated
        automatically. Like any other :class:`_engine.Transaction`, the
        :class:`_engine.NestedTransaction` may be used as a context manager as
        illustrated above which will "release" or "rollback" corresponding to
        if the operation within the block were successful or raised an
        exception.
 
        Nested transactions require SAVEPOINT support in the underlying
        database, else the behavior is undefined. SAVEPOINT is commonly used to
        run operations within a transaction that may fail, while continuing the
        outer transaction. E.g.::
 
            from sqlalchemy import exc
 
            with engine.begin() as connection:
                trans = connection.begin_nested()
                try:
                    connection.execute(table.insert(), {"username": "sandy"})
                    trans.commit()
                except exc.IntegrityError:  # catch for duplicate username
                    trans.rollback()  # rollback to savepoint
 
                # outer transaction continues
                connection.execute( ... )
 
        If :meth:`_engine.Connection.begin_nested` is called without first
        calling :meth:`_engine.Connection.begin` or
        :meth:`_engine.Engine.begin`, the :class:`_engine.Connection` object
        will "autobegin" the outer transaction first. This outer transaction
        may be committed using "commit-as-you-go" style, e.g.::
 
            with engine.connect() as connection:  # begin() wasn't called
 
                with connection.begin_nested(): will auto-"begin()" first
                    connection.execute( ... )
                # savepoint is released
 
                connection.execute( ... )
 
                # explicitly commit outer transaction
                connection.commit()
 
                # can continue working with connection here
 
        .. versionchanged:: 2.0
 
            :meth:`_engine.Connection.begin_nested` will now participate
            in the connection "autobegin" behavior that is new as of
            2.0 / "future" style connections in 1.4.
 
        .. seealso::
 
            :meth:`_engine.Connection.begin`
 
            :ref:`session_begin_nested` - ORM support for SAVEPOINT
 
        N)rLr¹r»rnrbrbrcÚ begin_nested[sI
zConnection.begin_nestedz Optional[Any]ÚTwoPhaseTransaction)ÚxidrfcCs2|jdk    rt d¡‚|dkr(|jj ¡}t||ƒS)a'Begin a two-phase or XA transaction and return a transaction
        handle.
 
        The returned object is an instance of :class:`.TwoPhaseTransaction`,
        which in addition to the methods provided by
        :class:`.Transaction`, also provides a
        :meth:`~.TwoPhaseTransaction.prepare` method.
 
        :param xid: the two phase transaction id.  If not supplied, a
          random id will be generated.
 
        .. seealso::
 
            :meth:`_engine.Connection.begin`
 
            :meth:`_engine.Connection.begin_twophase`
 
        NzOCannot start a two phase transaction when a transaction is already in progress.)rLrr¶rPrUZ
create_xidr½)r`r¾rbrbrcÚbegin_twophase©s
ÿ zConnection.begin_twophasecCs|jr|j ¡dS)aCommit the transaction that is currently in progress.
 
        This method commits the current transaction if one has been started.
        If no transaction was started, the method has no effect, assuming
        the connection is in a non-invalidated state.
 
        A transaction is begun on a :class:`_engine.Connection` automatically
        whenever a statement is first executed, or when the
        :meth:`_engine.Connection.begin` method is called.
 
        .. note:: The :meth:`_engine.Connection.commit` method only acts upon
          the primary database transaction that is linked to the
          :class:`_engine.Connection` object.  It does not operate upon a
          SAVEPOINT that would have been invoked from the
          :meth:`_engine.Connection.begin_nested` method; for control of a
          SAVEPOINT, call :meth:`_engine.NestedTransaction.commit` on the
          :class:`_engine.NestedTransaction` that is returned by the
          :meth:`_engine.Connection.begin_nested` method itself.
 
 
        N)rLÚcommitrnrbrbrcrÀÆszConnection.commitcCs|jr|j ¡dS)aYRoll back the transaction that is currently in progress.
 
        This method rolls back the current transaction if one has been started.
        If no transaction was started, the method has no effect.  If a
        transaction was started and the connection is in an invalidated state,
        the transaction is cleared using this method.
 
        A transaction is begun on a :class:`_engine.Connection` automatically
        whenever a statement is first executed, or when the
        :meth:`_engine.Connection.begin` method is called.
 
        .. note:: The :meth:`_engine.Connection.rollback` method only acts
          upon the primary database transaction that is linked to the
          :class:`_engine.Connection` object.  It does not operate upon a
          SAVEPOINT that would have been invoked from the
          :meth:`_engine.Connection.begin_nested` method; for control of a
          SAVEPOINT, call :meth:`_engine.NestedTransaction.rollback` on the
          :class:`_engine.NestedTransaction` that is returned by the
          :meth:`_engine.Connection.begin_nested` method itself.
 
 
        N)rLÚrollbackrnrbrbrcrÁßszConnection.rollbackz    List[Any]cCs|jj |¡Srˆ)rPrUZdo_recover_twophasernrbrbrcÚrecover_twophaseùszConnection.recover_twophase)r¾ÚrecoverrfcCs|jjj|||ddS©N)rÃ)rPrUÚdo_rollback_twophase©r`r¾rÃrbrbrcÚrollback_preparedüszConnection.rollback_preparedcCs|jjj|||ddSrÄ)rPrUÚdo_commit_twophaserÆrbrbrcÚcommit_preparedÿszConnection.commit_preparedcCs|jdk    o|jjS©z,Return True if a transaction is in progress.N)rLÚ    is_activernrbrbrcÚin_transactionszConnection.in_transactioncCs|jdk    o|jjSrÊ)rMrËrnrbrbrcÚin_nested_transactions
þz Connection.in_nested_transactioncCs0|j dd¡}t|dkp,|dko,|jjjdkƒS)NrZ
AUTOCOMMIT)rKr‚rOrPrUZ_on_connect_isolation_level)r`Zopt_isorbrbrcÚ_is_autocommit_isolation sÿüz#Connection._is_autocommit_isolationcCs|j}|dkrt d¡‚|S)Nz"connection is not in a transaction)rLrr¶©r`ZtransrbrbrcÚ_get_required_transactions
z$Connection._get_required_transactioncCs|j}|dkrt d¡‚|S)Nz)connection is not in a nested transaction)rMrr¶rÏrbrbrcÚ _get_required_nested_transactions ÿz+Connection._get_required_nested_transactioncCs|jS)zaReturn the current root transaction in progress, if any.
 
        .. versionadded:: 1.4
 
        )rLrnrbrbrcÚget_transaction&szConnection.get_transactioncCs|jS)zcReturn the current nested transaction in progress, if any.
 
        .. versionadded:: 1.4
 
        )rMrnrbrbrcÚget_nested_transaction/sz!Connection.get_nested_transaction)Ú transactionrfc
Cs |jr$| ¡r| d¡n
| d¡d|_|js8|jjrD|j |¡zNz|jj     |j
¡Wn4t k
rŽ}z|  |dddd¡W5d}~XYnXW5d|_XdS)Nz?BEGIN (implicit; DBAPI should not BEGIN due to autocommit mode)zBEGIN (implicit)TF) r^rÎr}r[rRrPrHr¸rUZdo_beginrQr¨r©©r`rÔr«rbrbrcÚ _begin_impl7sÿ
 (zConnection._begin_implc
Cs’|js|jjr|j |¡|jrŽ|jrD| ¡r:| d¡n
| d¡z|jj     |j
¡Wn4t k
rŒ}z|  |dddd¡W5d}~XYnXdS)NzVROLLBACK using DBAPI connection.rollback(), DBAPI should ignore due to autocommit modeZROLLBACK) rRrPrHrÁr¡r^rÎr}rUZ do_rollbackrQr¨r©rªrbrbrcÚ_rollback_implMs ÿ
zConnection._rollback_implc
CsŒ|js|jjr|j |¡|jr>| ¡r4| d¡n
| d¡z|jj |j    ¡Wn4t
k
r†}z|  |dddd¡W5d}~XYnXdS)NzRCOMMIT using DBAPI connection.commit(), DBAPI should ignore due to autocommit modeZCOMMIT) rRrPrHrÀr^rÎr}rUZ    do_commitrQr¨r©rªrbrbrcÚ _commit_impl_s ÿ
zConnection._commit_impl)r†rfcCsP|js|jjr|j ||¡|dkr<|jd7_d|j}|jj ||¡|S)Nrzsa_savepoint_%s)rRrPrHZ    savepointrZrUZ do_savepoint©r`r†rbrbrcÚ_savepoint_implqs
zConnection._savepoint_implcCs8|js|jjr|j ||d¡|jr4|jj ||¡dSrˆ)rRrPrHZrollback_savepointr¡rUZdo_rollback_to_savepointrÙrbrbrcÚ_rollback_to_savepoint_impl{sz&Connection._rollback_to_savepoint_implcCs2|js|jjr|j ||d¡|jj ||¡dSrˆ)rRrPrHZrelease_savepointrUZdo_release_savepointrÙrbrbrcÚ_release_savepoint_impl‚sz"Connection._release_savepoint_implc
Cs’|jr| d¡|js|jjr.|j ||j¡d|_zPz|jj     ||j¡Wn4t
k
r€}z|  |dddd¡W5d}~XYnXW5d|_XdS)NzBEGIN TWOPHASE (implicit)TF) r^r}rRrPrHr¿r¾r[rUZdo_begin_twophaser¨r©rÕrbrbrcÚ_begin_twophase_implˆs
(zConnection._begin_twophase_implc
Csz|js|jjr|j ||¡t|jtƒs,t‚z|jj     ||¡Wn4t
k
rt}z|  |dddd¡W5d}~XYnXdSrˆ) rRrPrHZprepare_twophaseÚ
isinstancerLr½r­rUZdo_prepare_twophaser¨r©)r`r¾r«rbrbrcÚ_prepare_twophase_impl–sz!Connection._prepare_twophase_impl)r¾Ú is_preparedrfc
Cs„|js|jjr|j |||¡|jr€t|jtƒs4t‚z|jj     
|||¡Wn4t k
r~}z|  |dddd¡W5d}~XYnXdSrˆ) rRrPrHZrollback_twophaser¡rÞrLr½r­rUrÅr¨r©©r`r¾ràr«rbrbrcÚ_rollback_twophase_impl sÿz"Connection._rollback_twophase_implc
Cs~|js|jjr|j |||¡t|jtƒs.t‚z|jj     |||¡Wn4t
k
rx}z|  |dddd¡W5d}~XYnXdSrˆ) rRrPrHZcommit_twophaserÞrLr½r­rUrÈr¨r©rárbrbrcÚ_commit_twophase_impl­sz Connection._commit_twophase_implcCsZ|jr|j ¡d}nd}|jdk    rP|j}|rBtd|ƒjddn| ¡d|_d|_dS)aßClose this :class:`_engine.Connection`.
 
        This results in a release of the underlying database
        resources, that is, the DBAPI connection referenced
        internally. The DBAPI connection is typically restored
        back to the connection-holding :class:`_pool.Pool` referenced
        by the :class:`_engine.Engine` that produced this
        :class:`_engine.Connection`. Any transactional state present on
        the DBAPI connection is also unconditionally released via
        the DBAPI connection's ``rollback()`` method, regardless
        of any :class:`.Transaction` object that may be
        outstanding with regards to this :class:`_engine.Connection`.
 
        This has the effect of also calling :meth:`_engine.Connection.rollback`
        if any transaction is in place.
 
        After :meth:`_engine.Connection.close` is called, the
        :class:`_engine.Connection` is permanently in a closed state,
        and will allow no further operations.
 
        TFNr4)Ztransaction_reset)rLrrJrZ_close_specialr\)r`Z
skip_resetÚconnrbrbrcr·s
 
 
ÿzConnection.close©r™zTypedReturnsRows[Tuple[_T]]z"Optional[_CoreSingleExecuteParams]z%Optional[CoreExecuteOptionsParameter]z Optional[_T])Ú    statementÚ
parametersr™rfcCsdSrˆrb©r`rærçr™rbrbrcÚscalarçszConnection.scalarr7cCsdSrˆrbrèrbrbrcréñsc
CsVt|ƒ}z
|j}Wn.tk
r@}zt |¡|‚W5d}~XYnX||||pNtƒSdS)auExecutes a SQL statement construct and returns a scalar object.
 
        This method is shorthand for invoking the
        :meth:`_engine.Result.scalar` method after invoking the
        :meth:`_engine.Connection.execute` method.  Parameters are equivalent.
 
        :return: a scalar Python value representing the first column of the
         first row returned.
 
        N)rZ_execute_on_scalarÚAttributeErrorrÚObjectNotExecutableErrorrE©r`rærçr™Údistilled_parametersÚmethrarbrbrcréûs
ýzOptional[_CoreAnyExecuteParams]zScalarResult[_T]cCsdSrˆrbrèrbrbrcÚscalarsszConnection.scalarszScalarResult[Any]cCsdSrˆrbrèrbrbrcrï"scCs|j|||d ¡S)aÐExecutes and returns a scalar result set, which yields scalar values
        from the first column of each row.
 
        This method is equivalent to calling :meth:`_engine.Connection.execute`
        to receive a :class:`_result.Result` object, then invoking the
        :meth:`_result.Result.scalars` method to produce a
        :class:`_result.ScalarResult` instance.
 
        :return: a :class:`_result.ScalarResult`
 
        .. versionadded:: 1.4.24
 
        rå)Úexecuterïrèrbrbrcrï,s
ÿzTypedReturnsRows[_T]zCursorResult[_T]cCsdSrˆrbrèrbrbrcrðEszConnection.executezCursorResult[Any]cCsdSrˆrbrèrbrbrcrðOsc
CsVt|ƒ}z
|j}Wn.tk
r@}zt |¡|‚W5d}~XYnX||||pNtƒSdS)a¼Executes a SQL statement construct and returns a
        :class:`_engine.CursorResult`.
 
        :param statement: The statement to be executed.  This is always
         an object that is in both the :class:`_expression.ClauseElement` and
         :class:`_expression.Executable` hierarchies, including:
 
         * :class:`_expression.Select`
         * :class:`_expression.Insert`, :class:`_expression.Update`,
           :class:`_expression.Delete`
         * :class:`_expression.TextClause` and
           :class:`_expression.TextualSelect`
         * :class:`_schema.DDL` and objects which inherit from
           :class:`_schema.ExecutableDDLElement`
 
        :param parameters: parameters which will be bound into the statement.
         This may be either a dictionary of parameter names to values,
         or a mutable sequence (e.g. a list) of dictionaries.  When a
         list of dictionaries is passed, the underlying statement execution
         will make use of the DBAPI ``cursor.executemany()`` method.
         When a single dictionary is passed, the DBAPI ``cursor.execute()``
         method will be used.
 
        :param execution_options: optional dictionary of execution options,
         which will be associated with the statement execution.  This
         dictionary can provide a subset of the options that are accepted
         by :meth:`_engine.Connection.execution_options`.
 
        :return: a :class:`_engine.Result` object.
 
        N)rZ_execute_on_connectionrêrrërErìrbrbrcrðYs&
ýzFunctionElement[Any]r'r-)Úfuncrír™rfcCs| | ¡||¡S)z%Execute a sql.FunctionElement object.)Ú_execute_clauseelementÚselect)r`rñrír™rbrbrcÚ_execute_function‹s
ÿzConnection._execute_functionr>)Údefaultrír™rfc
Csô|j |¡}|js|jjr2| |||¡\}}}}nd}}z2|j}|dkrR| ¡}|j}|j     ||||¡}WnPt
j t
j fk
rЂYn4t k
r¼}    z| |    dddd¡W5d}    ~    XYnX| d|d¡}
|jsÚ|jjrð|j ||||||
¡|
S)z&Execute a schema.ColumnDefault object.N)rKÚ
merge_withrRrPÚ_invoke_before_exec_eventrJr¥rUÚexecution_ctx_clsZ _init_defaultrr¦r§r¨r©Z _exec_defaultrHÚ after_execute) r`rõrír™Úevent_multiparamsÚ event_paramsrärUÚctxr«ÚretrbrbrcÚ_execute_default—sTÿ ÿûü    ÿ$ú    zConnection._execute_defaultr:)Úddlrír™rfc Csª|j |j|¡}|js|jjr6| |||¡\}}}}nd}}|j |¡}| dd¡}|j}|j||d}    | ||j    j
|    d||    ¡}
|js|jjr¦|j   ||||||
¡|
S)zExecute a schema.DDL object.Nr)rUr) rKrörRrPr÷r‚rUÚcompileÚ_execute_contextrøZ    _init_ddlrHrù) r`rÿrír™rúrûZ    exec_optsrrUÚcompiledrýrbrbrcÚ _execute_ddlÒsTÿÿûü      ÿúúzConnection._execute_ddlzVTuple[Any, _CoreMultiExecuteParams, _CoreMultiExecuteParams, _CoreSingleExecuteParams])ÚelemÚdistilled_paramsr™rfcCs‚t|ƒdkrg|d}}n
|i}}|jjD]}||||||ƒ\}}}q.|rft|ƒ}|rvt d¡‚n|rr|g}ng}||||fS)NrrzLEvent handler can't return non-empty multiparams and params at the same time)ÚlenrHZbefore_executeÚlistrr¶)r`rrr™rúrûÚfnrbrbrcr÷s* 
 û ÿz$Connection._invoke_before_exec_event)rrír™rfc Csæ|j |j|¡}|jp|jj}|r8| |||¡\}}}}|rVt|dƒ}t|ƒdk}ng}d}|j}    | dd¡}
| d|jj    ¡} |j
|    | |||
|jj t j Bd\} } }|j|    |    jj| ||| ||| |d
}|râ|j ||||||¡|S)    z#Execute a sql.ClauseElement object.rrFrNr)rUrZ column_keysÚfor_executemanyrZlinting)Ú    cache_hit)rKrörRrPr÷ÚsortedrrUr‚Ú_compiled_cacheZ_compile_w_cacheZcompiler_lintingr!Z WARN_LINTINGrrøÚ_init_compiledrHrù)r`rrír™Z
has_eventsrúrûÚkeysr    rUrrZ compiled_sqlZextracted_paramsr
rýrbrbrcrò3sxÿÿû ÿÿ ú ö úz!Connection._execute_clauseelementr9)rrír™rfc Cs€|j |j|¡}|js|jjr4| |||¡\}}}}|j}| ||jj    |||||dd¡    }|jsf|jjr||j
  ||||||¡|S)ziExecute a sql.Compiled object.
 
        TODO: why do we have this?   likely deprecate or remove
 
        N) r™rörKrRrPr÷rUrrør rHrù)r`rrír™rúrûrUrýrbrbrcÚ_execute_compiled|sJ ÿÿû÷ úzConnection._execute_compiledú Optional[_DBAPIAnyExecuteParams]c    Cs8t|ƒ}|j |¡}|j}| ||jj|d|||¡}|S)aExecutes a SQL statement construct and returns a
        :class:`_engine.CursorResult`.
 
        :param statement: The statement str to be executed.   Bound parameters
         must use the underlying DBAPI's paramstyle, such as "qmark",
         "pyformat", "format", etc.
 
        :param parameters: represent bound parameter values to be used in the
         execution.  The format is one of:   a dictionary of named parameters,
         a tuple of positional parameters, or a list containing either
         dictionaries or tuples for multiple-execute support.
 
         E.g. multiple dictionaries::
 
 
             conn.exec_driver_sql(
                 "INSERT INTO table (id, value) VALUES (%(id)s, %(value)s)",
                 [{"id":1, "value":"v1"}, {"id":2, "value":"v2"}]
             )
 
         Single dictionary::
 
             conn.exec_driver_sql(
                 "INSERT INTO table (id, value) VALUES (%(id)s, %(value)s)",
                 dict(id=1, value="v1")
             )
 
         Single tuple::
 
             conn.exec_driver_sql(
                 "INSERT INTO table (id, value) VALUES (?, ?)",
                 (1, 'v1')
             )
 
         .. note:: The :meth:`_engine.Connection.exec_driver_sql` method does
             not participate in the
             :meth:`_events.ConnectionEvents.before_execute` and
             :meth:`_events.ConnectionEvents.after_execute` events.   To
             intercept calls to :meth:`_engine.Connection.exec_driver_sql`, use
             :meth:`_events.ConnectionEvents.before_cursor_execute` and
             :meth:`_events.ConnectionEvents.after_cursor_execute`.
 
         .. seealso::
 
            :pep:`249`
 
        N)rrKrörUrrøZ_init_statement)r`rærçr™rírUrýrbrbrcÚexec_driver_sql®s6ÿù
zConnection.exec_driver_sqlr.zCallable[..., ExecutionContext]zUnion[str, Compiled]z Optional[_AnyMultiExecuteParams])rUÚ constructorrærçr™Úargsrtrfc
Os(|r$| dd¡}|r$| d|dœ¡}z0|j}    |    dkr<| ¡}    ||||    |f|ž|Ž}
WnTtjtjfk
rr‚Yn8tk
r¨} z| | t    |ƒ|dd¡W5d} ~ XYnX|j
r¸|j
j rÆ|j rÐ|j j sÐ|  ¡n|jràt |¡|j
dkrò| ¡|
 ¡|
jtjkr| ||
¡S| ||
||¡SdS)zdCreate an :class:`.ExecutionContext` and execute, returning
        a :class:`_engine.CursorResult`.r”NT)r’r“)r‚rœrJr¥rr¦r§r¨r©rprLrËrMr²rIrÚ_trans_ctx_checkr¹Zpre_execÚ execute_stylerZINSERTMANYVALUESÚ_exec_insertmany_contextÚ_exec_single_context) r`rUrrærçr™rrtZypräÚcontextr«rbrbrcr÷sn  ÿÿÿÿÿÿþüû
 
 
þÿzConnection._execute_contextr)rUrrærçrfc
Cs¬|jtjkrf| ¡}|rfz| |j||¡Wn8tk
rd}z| |t|ƒ|d|¡W5d}~XYnX|j|j    |j
}}}|j sŒ|d}    n|}    |j sž|j j rÄ|jjD]}
|
||||    ||j ƒ\}}    q¦|jr| |¡| ¡} |j js| d| tj|    d|j d¡n | d| ¡d} zX|jtjkr‚td|    ƒ}    |jj rh|jjjD] }
|
|||    |ƒrFd    } qhqF| s4|j |||    |¡n²|    sÜ|jrÜ|jj rÄ|jjjD]}
|
|||ƒr¤d    } qĐq¤| s4|j |||¡nXtd
|    ƒ}    |jj r|jjjD] }
|
|||    |ƒrúd    } qqú| s4|j |||    |¡|j sF|j j r^|j ||||    ||j ¡|  ¡| !¡} Wn6tk
r¦}z| |||    ||¡W5d}~XYnX| S) zzcontinue the _execute_context() method for a single DBAPI
        cursor.execute() or cursor.executemany() call.
 
        Nrú[%s] %ré
©ZbatchesÚismultiú8[%s] [SQL parameters hidden due to hide_parameters=True]Fr'Tr()"Ú bind_typingrÚ SETINPUTSIZESÚ_prepare_set_input_sizesÚdo_set_input_sizesÚcursorr¨r©rprærçÚ executemanyrRrPrHÚbefore_cursor_executer^r}Ú_get_cache_statsÚhide_parametersÚsql_utilÚ _repr_paramsrrZ EXECUTEMANYrrUZdo_executemanyr‘Zdo_execute_no_paramsÚ
do_executeÚafter_cursor_executeÚ    post_execÚ_setup_result_proxy)r`rUrrærçÚgeneric_setinputsizesr«r"Ú str_statementÚeffective_parametersrÚstatsZ evt_handledÚresultrbrbrcr5s ÿÿý
 
 ú
    
 
ýý
þÿ
ü
ü
 
ÿÿ
ü
ÿú     ÿzConnection._exec_single_context)rUrrfc Csž|jtjkr| ¡}nd}|j|j|j}}}|}|jp@|jj}|j    jrV|j    j
j }    nd}    |j rl|  ¡d}
| |||||¡D]Ì} | jràz| |j| j|¡Wn>tk
rÞ} z | | t | j¡| jd|¡W5d} ~ XYnX| j} | j}|r|j
jD]}|||| ||dƒ\} }qú|j r¸| t | ¡¡d| j›d| j›d| jrLdnd    ›| jr\d
nd ›d }| jd kr||
|7}
n
d|›}
|jjs¬| d|
tj|ddd¡n | d|
¡z6|    D]}||| ||ƒr¾qìq¾|  || ||¡Wn@tk
r.} z |j| t | ¡|||ddW5d} ~ XYnX|r~|j
 ||||||j ¡q~z| !¡| "¡}Wn6tk
r˜} z| | ||||¡W5d} ~ XYnX|S)zÒcontinue the _execute_context() method for an "insertmanyvalues"
        operation, which will invoke DBAPI
        cursor.execute() one or more times with individual log and
        event hook calls.
 
        Nrbz (insertmanyvalues)Tú ú/z (ZorderedÚ    unorderedz; batch not supportedr°ú)rZinsertmanyvaluesrrFrr)Ú is_sub_exec)#rrrr r"rærçrRrPrUrHr)r^r%Z!_deliver_insertmanyvalues_batchesZprocessed_setinputsizesr!r¨r©r'Z_long_statementZreplaced_statementZreplaced_parametersr$r}ZbatchnumZ total_batchesZ rows_sortedZ is_downgradedr&r(r*r#r+r,)r`rUrr-r"r.rçr/Z engine_eventsZdo_execute_dispatchr0Z    imv_batchr«Zsub_stmtZ
sub_paramsrZ    imv_statsr1rbrbrcrÄsü 
ý
þ û
ý
û ú
    ÿÿÿýÿù
 
 
 
ýý
ýü
üú    ú     ÿz#Connection._exec_insertmany_contextrr*úOptional[ExecutionContext])r"rærçrrfc
Csð|js|jjr2|jjD]}||||||dƒ\}}q|jrN| |¡| d|¡zD|jjs\dn|jjjD]}|||||ƒrfqqf|j ||||¡Wn4tk
rÆ}z|     |||||¡W5d}~XYnX|jsÖ|jjrì|j 
|||||d¡dS)a_Execute a statement + params on the given cursor.
 
        Adds appropriate logging and exception handling.
 
        This method is used by DefaultDialect for special-case
        executions, such as for sequences and column defaults.
        The path of statement execution in the majority of cases
        terminates at _execute_context().
 
        Fz [raw sql] %rrbN) rRrPrHr$r^r}rUr)r¨r©r*)r`r"rærçrrr«rbrbrcÚ_cursor_executecsL ÿ
 
 ÿýÿÿzConnection._cursor_execute)r"rfcCs:z | ¡Wn(tk
r4|jjjjdddYnXdS)z\Close the given cursor, catching exceptions
        and turning into log warnings.
 
        zError closing cursorT)Úexc_infoN)rÚ    ExceptionrPÚpoolryÚerror)r`r"rbrbrcÚ_safe_close_cursor‘s 
ÿzConnection._safe_close_cursorr¨zOptional[_AnyExecuteParams]úOptional[DBAPICursor])r«rærçr"rr6rfc Csèt ¡}t |¡}|jsZt||jjjƒrL|j     rL|j 
||j sD|j nd|¡pV|oV|j     |_| }    |dk    rt| ov|j nd}
|jr°tjj||||jjj|jj|j|
d |d¡|‚d|_zÜt||jjjƒpÞ|dk    oÞ|dkoÞ| } | rtjj||tt|ƒ|jjj|jj|j|j|
d} nd} d}|jjrð|j dd¡sðt|| |j|j||||||j|    dƒ }|jjj D]\}z ||ƒ}|dk    rŠ||_!}Wn4tk
rÀ}z|}WY¢
qÆW5d}~XYnXqh|j|j
krê|j
|_| rê|j
| _"|j#}    | r|r| $|¡|js0|r| %|¡| &¡s0| '¡|rH| |d¡|‚nJ| rn| dk    s\t‚|  |d¡|‚n$|ddk    s€t‚|d |d¡‚W5|`|jrâ|`|j sâ|j } | dk    sÂt‚|    rØ|jj | |¡| |¡XdS)NF)r&rUrrT)r&Úconnection_invalidatedrUrZskip_user_error_eventsr)(Úsysr9r Úis_exit_exceptionÚ_is_disconnectrÞrUrWrXr£Ú is_disconnectr¤rJr#Ú_reentrant_errorrÚ
DBAPIErrorÚinstancerPr&Úwith_tracebackr­r;Z _invalidaterµrr:rRrKr‚ÚExceptionContextImplrHÚ handle_errorÚchained_exceptionr?Úinvalidate_pool_on_disconnectZhandle_dbapi_exceptionr=rÌr×)r`r«rærçr"rr6r9rArKrZdbapi_conn_wrapperÚ should_wrapÚsqlalchemy_exceptionÚnewraiserürÚper_fnÚ_raisedrbrbrcr©¡sÜ    
ÿýý
ø
ÿýùøø    ÿýø ÿô
"ÿÿ 
 
 
z"Connection._handle_dbapi_exceptionúOptional[Engine])r«rUrPrCrKÚ is_pre_pingrfc Cs‚t ¡}|dkr,t||jjƒo*| |dd¡}t||jjƒ}|rrtjjddt    t
|ƒ|jj|dk    rd|j nd||d}    nd}    d}
|j rt ||    ||ddddd|||ƒ } |jjD]T} z| | ƒ} | dk    rÈ| | _}
Wq¨t
k
rú}z|}
WY¢qþW5d}~XYq¨Xq¨|    r|| jkr| j|    _}|
r4|
 |d¡|‚nJ|rZ|    dk    sHt‚|     |d¡|‚n$|ddk    slt‚|d |d¡‚dS)NF)r&r?rUrr)r@r9rÞrWrXrCrrErFrr:r&rRrHrHrIrJr?rGr­)Úclsr«rUrPrCrKrRr9rLrMrNrürrOrPrbrbrcrY2    sr
ÿ þÿ÷ ô þz/Connection._handle_dbapi_exception_noconnectionú+Type[Union[SchemaGenerator, SchemaDropper]]r@©ÚvisitorcallableÚelementÚkwargsrfcKs||j|f|Ž |¡dS)z®run a DDL visitor.
 
        This method is only here so that the MockConnection can change the
        options given to the visitor so that "checkfirst" is skipped.
 
        N)rUZtraverse_single)r`rVrWrXrbrbrcÚ_run_ddl_visitor    s zConnection._run_ddl_visitor)NNTT)N)N)F)F)N)N)N)N)N)N)N)N)N)N)NN)N)F)NNTF)RÚ__name__Ú
__module__Ú __qualname__Ú__doc__Ú__annotations__Ú_sqla_logger_namespacerIZshould_close_with_resultrdr Zmemoized_propertyror}rÚpropertyrƒr‡r‰rŽr r™rr¡r£r¤rQr®r¯r²r¥rzrµr·r¹r¸r¼r¿rÀrÁrÂrÇrÉrÌrÍrÎrÐrÑrÒrÓrÖr×rØrÚrÛrÜrÝrßrârãrrérïrðrôrþrr÷ròrDrrrrrr8r=rDrBr©Ú classmethodrYrYrbrbrbrcrFWs6
 ú-  õ(} , ;$LN     
 
 
0ýû    ýû ýûýû    ýû ýûýû    ýû ýû2 ;6+Mü5üI>%û.     ùùLrFr0c @s8eZdZdZdZddddddd    d
d d d d d œ dd„ZdS)rHz3Implement the :class:`.ExceptionContext` interface.) rQrPrUr"rærçÚoriginal_exceptionrMrJÚexecution_contextrCrKrRr¨zOptional[exc.StatementError]rQr.úOptional[Connection]r>r„rr7rO) r´rMrPrUrQr"rærçrrCrKrRc CsF||_||_||_||_||_|    |_||_||_|
|_| |_    | |_
dSrˆ) rPrUrQrMrbrcrærçrCrKrR) r`r´rMrPrUrQr"rærçrrCrKrRrbrbrcrd¡    szExceptionContextImpl.__init__N)rZr[r\r]Ú    __slots__rdrbrbrbrcrHŽ    srHc@sðeZdZUdZdZdZded<ded<ded<dd    œd
d „Zedd œd d„ƒZ    dd œdd„Z
dd œdd„Z dd œdd„Z edd œdd„ƒZ dd œdd„Zdd œdd„Zdd œdd„Zdd œdd„Zdd œd d!„Zdd œd"d#„Zdd œd$d%„Zd&S)'Ú Transactiona}Represent a database transaction in progress.
 
    The :class:`.Transaction` object is procured by
    calling the :meth:`_engine.Connection.begin` method of
    :class:`_engine.Connection`::
 
        from sqlalchemy import create_engine
        engine = create_engine("postgresql+psycopg2://scott:tiger@localhost/test")
        connection = engine.connect()
        trans = connection.begin()
        connection.execute(text("insert into x (a, b) values (1, 2)"))
        trans.commit()
 
    The object provides :meth:`.rollback` and :meth:`.commit`
    methods in order to control transaction boundaries.  It
    also implements a context manager interface so that
    the Python ``with`` statement can be used with the
    :meth:`_engine.Connection.begin` method::
 
        with connection.begin():
            connection.execute(text("insert into x (a, b) values (1, 2)"))
 
    The Transaction object is **not** threadsafe.
 
    .. seealso::
 
        :meth:`_engine.Connection.begin`
 
        :meth:`_engine.Connection.begin_twophase`
 
        :meth:`_engine.Connection.begin_nested`
 
    .. index::
      single: thread safety; Transaction
    rbFrOÚ_is_rootrËrFrQ©rQcCs
tƒ‚dSrˆ©ÚNotImplementedError©r`rQrbrbrcrdè    szTransaction.__init__recCs
tƒ‚dS)zƒTrue if this transaction is totally deactivated from the connection
        and therefore can no longer affect its state.
 
        NrirnrbrbrcÚ_deactivated_from_connectionë    sz(Transaction._deactivated_from_connectionrqcCs
tƒ‚dSrˆrirnrbrbrcÚ    _do_closeó    szTransaction._do_closecCs
tƒ‚dSrˆrirnrbrbrcÚ _do_rollbackö    szTransaction._do_rollbackcCs
tƒ‚dSrˆrirnrbrbrcÚ
_do_commitù    szTransaction._do_commitcCs|jo|jj Srˆ)rËrQr¤rnrbrbrcržü    szTransaction.is_validcCsz | ¡W5|jrt‚XdS)a;Close this :class:`.Transaction`.
 
        If this transaction is the base transaction in a begin/commit
        nesting, the transaction will rollback().  Otherwise, the
        method returns.
 
        This is used to cancel a Transaction without affecting the scope of
        an enclosing transaction.
 
        N)rËr­rmrnrbrbrcr
s  zTransaction.closecCsz | ¡W5|jrt‚XdS)aíRoll back this :class:`.Transaction`.
 
        The implementation of this may vary based on the type of transaction in
        use:
 
        * For a simple database transaction (e.g. :class:`.RootTransaction`),
          it corresponds to a ROLLBACK.
 
        * For a :class:`.NestedTransaction`, it corresponds to a
          "ROLLBACK TO SAVEPOINT" operation.
 
        * For a :class:`.TwoPhaseTransaction`, DBAPI-specific methods for two
          phase transactions may be used.
 
 
        N)rËr­rnrnrbrbrcrÁ
s zTransaction.rollbackcCsz | ¡W5|jrt‚XdS)aãCommit this :class:`.Transaction`.
 
        The implementation of this may vary based on the type of transaction in
        use:
 
        * For a simple database transaction (e.g. :class:`.RootTransaction`),
          it corresponds to a COMMIT.
 
        * For a :class:`.NestedTransaction`, it corresponds to a
          "RELEASE SAVEPOINT" operation.
 
        * For a :class:`.TwoPhaseTransaction`, DBAPI-specific methods for two
          phase transactions may be used.
 
        N)rËr­rornrbrbrcrÀ&
s zTransaction.commitcCs|jSrˆrhrnrbrbrcÚ _get_subject;
szTransaction._get_subjectcCs|jSrˆ)rËrnrbrbrcÚ_transaction_is_active>
sz"Transaction._transaction_is_activecCs|j Srˆ)rlrnrbrbrcÚ_transaction_is_closedA
sz"Transaction._transaction_is_closedcCsdS©NTrbrnrbrbrcÚ_rollback_can_be_calledD
sz#Transaction._rollback_can_be_calledN)rZr[r\r]rergr^rdr`rlrmrnroržrrÁrÀrprqrrrtrbrbrbrcrf½    s(
$ rfc@s¬eZdZdZdZdZddœdd„Zdd    œd
d „Zed d    œd d„ƒZ    dd    œdd„Z
dd    œdd„Z dd    œdd„Z d d ddœdd„Z dd    œdd„Zdd    œdd„Zdd    œdd„ZdS)!rºaýRepresent the "root" transaction on a :class:`_engine.Connection`.
 
    This corresponds to the current "BEGIN/COMMIT/ROLLBACK" that's occurring
    for the :class:`_engine.Connection`. The :class:`_engine.RootTransaction`
    is created by calling upon the :meth:`_engine.Connection.begin` method, and
    remains associated with the :class:`_engine.Connection` throughout its
    active span. The current :class:`_engine.RootTransaction` in use is
    accessible via the :attr:`_engine.Connection.get_transaction` method of
    :class:`_engine.Connection`.
 
    In :term:`2.0 style` use, the :class:`_engine.Connection` also employs
    "autobegin" behavior that will create a new
    :class:`_engine.RootTransaction` whenever a connection in a
    non-transactional state is used to emit commands on the DBAPI connection.
    The scope of the :class:`_engine.RootTransaction` in 2.0 style
    use can be controlled using the :meth:`_engine.Connection.commit` and
    :meth:`_engine.Connection.rollback` methods.
 
 
    T)rQrËrFrhcCs<|jdkst‚|jrt |¡||_| ¡||_d|_dSrs)rLr­rIrrrQÚ_connection_begin_implrËrkrbrbrcrdf
s
zRootTransaction.__init__rqrecCs8|jr|jj|kst‚d|_n|jj|k    r4t d¡dS)NFz0transaction already deassociated from connection)rËrQrLr­r ÚwarnrnrbrbrcÚ_deactivate_from_connectionp
s
 z+RootTransaction._deactivate_from_connectionrOcCs |jj|k    Srˆ)rQrLrnrbrbrcrlx
sz,RootTransaction._deactivated_from_connectioncCs|j |¡dSrˆ)rQrÖrnrbrbrcru|
sz&RootTransaction._connection_begin_implcCs|j ¡dSrˆ)rQr×rnrbrbrcÚ_connection_rollback_impl
sz)RootTransaction._connection_rollback_implcCs|j ¡dSrˆ)rQrØrnrbrbrcÚ_connection_commit_impl‚
sz'RootTransaction._connection_commit_implF)Útry_deactivaterfcCsnz&|jr| ¡|jjr$|jj ¡W5|js2|r:| ¡|jj|krNd|j_X|jrZt‚|jj|k    sjt‚dSrˆ)rËrwrQrLrxrMÚ_cancelr­)r`rzrbrbrcÚ _close_impl…
s
 
 
zRootTransaction._close_implcCs | ¡dSrˆ©r|rnrbrbrcrm•
szRootTransaction._do_closecCs|jdddS)NT)rzr}rnrbrbrcrn˜
szRootTransaction._do_rollbackcCsŒ|jrL|jj|kst‚z | ¡W5|jjr8|jj ¡| ¡Xd|j_n"|jj|krd|j ¡n
t     
d¡‚|jrxt‚|jj|k    sˆt‚dS)NúThis transaction is inactive) rËrQrLr­rMr{rwryr²rr¶rnrbrbrcro›
s  
 
 
 
zRootTransaction._do_commitN)F)rZr[r\r]rgrerdrwr`rlrurxryr|rmrnrorbrbrbrcrºL
s
rºc@sšeZdZUdZdZded<ddœdd„Zdd
d d œd d„Zed
dœdd„ƒZ    d dœdd„Z
d
d
d dœdd„Z d dœdd„Z d dœdd„Z d dœdd„ZdS)r»a Represent a 'nested', or SAVEPOINT transaction.
 
    The :class:`.NestedTransaction` object is created by calling the
    :meth:`_engine.Connection.begin_nested` method of
    :class:`_engine.Connection`.
 
    When using :class:`.NestedTransaction`, the semantics of "begin" /
    "commit" / "rollback" are as follows:
 
    * the "begin" operation corresponds to the "BEGIN SAVEPOINT" command, where
      the savepoint is given an explicit name that is part of the state
      of this object.
 
    * The :meth:`.NestedTransaction.commit` method corresponds to a
      "RELEASE SAVEPOINT" operation, using the savepoint identifier associated
      with this :class:`.NestedTransaction`.
 
    * The :meth:`.NestedTransaction.rollback` method corresponds to a
      "ROLLBACK TO SAVEPOINT" operation, using the savepoint identifier
      associated with this :class:`.NestedTransaction`.
 
    The rationale for mimicking the semantics of an outer transaction in
    terms of savepoints so that code may deal with a "savepoint" transaction
    and an "outer" transaction in an agnostic way.
 
    .. seealso::
 
        :ref:`session_begin_nested` - ORM version of the SAVEPOINT API.
 
    )rQrËÚ
_savepointÚ_previous_nestedrprrFrhcCsH|jdk    st‚|jrt |¡||_|j ¡|_d|_|j    |_
||_    dSrs) rLr­rIrrrQrÚrrËrMr€rkrbrbrcrdÜ
s
 zNestedTransaction.__init__TrOrq)rvrfcCs*|jj|kr|j|j_n|r&t d¡dS)Nz7nested transaction already deassociated from connection)rQrMr€r rv)r`rvrbrbrcrwæ
s   ÿz-NestedTransaction._deactivate_from_connectionrecCs |jj|k    Srˆ)rQrMrnrbrbrcrlî
sz.NestedTransaction._deactivated_from_connectioncCs"d|_| ¡|jr|j ¡dS©NF)rËrwr€r{rnrbrbrcr{ò
szNestedTransaction._cancel)Údeactivate_from_connectionÚwarn_already_deactiverfc    Csfz*|jr(|jjr(|jjjr(|j |j¡W5d|_|rB|j|dX|jrNt‚|rb|jj|k    sbt‚dS)NF)rv)rËrwrQrLrÛrr­rM)r`r‚rƒrbrbrcr|û
sÿþý
zNestedTransaction._close_implcCs| dd¡dS)NTFr}rnrbrbrcrm szNestedTransaction._do_closecCs| dd¡dSrsr}rnrbrbrcrn szNestedTransaction._do_rollbackcCsR|jr,z|j |j¡W5d|_X| ¡n"|jj|krD|j ¡n
t d¡‚dS)NFz#This nested transaction is inactive)    rËrQrÜrrwrMr²rr¶rnrbrbrcro s
  ÿzNestedTransaction._do_commitN)T)rZr[r\r]rer^rdrwr`rlr{r|rmrnrorbrbrbrcr»¸
s
 
    r»csneZdZUdZdZded<dddœ‡fdd„ Zd    d
œd d „Zd    d
œd d„Zd    d
œdd„Z    d    d
œdd„Z
‡Z S)r½aRepresent a two-phase transaction.
 
    A new :class:`.TwoPhaseTransaction` object may be procured
    using the :meth:`_engine.Connection.begin_twophase` method.
 
    The interface is the same as that of :class:`.Transaction`
    with the addition of the :meth:`prepare` method.
 
    )r¾Ú _is_preparedrr¾rF)rQr¾csd|_||_tƒ |¡dSr)r„r¾Úsuperrd)r`rQr¾©Ú    __class__rbrcrd9 szTwoPhaseTransaction.__init__rqrecCs(|jst d¡‚|j |j¡d|_dS)zqPrepare this :class:`.TwoPhaseTransaction`.
 
        After a PREPARE, the transaction can be committed.
 
        r~TN)rËrr¶rQrßr¾r„rnrbrbrcÚprepare> s
zTwoPhaseTransaction.preparecCs|j |¡dSrˆ)rQrÝrnrbrbrcruI sz*TwoPhaseTransaction._connection_begin_implcCs|j |j|j¡dSrˆ)rQrâr¾r„rnrbrbrcrxL sz-TwoPhaseTransaction._connection_rollback_implcCs|j |j|j¡dSrˆ)rQrãr¾r„rnrbrbrcryO sz+TwoPhaseTransaction._connection_commit_impl) rZr[r\r]rer^rdrˆrurxryÚ __classcell__rbrbr†rcr½* s
 
 r½c
@söeZdZUdZded<ded<eZded<dZd    ed
<eZ    d ed <d Z
ded<dZ d    ed<dZ ded<ded<ded<ded<ded<d    ed<dZdddddd d!d    d"œd#d$„Z d%d&d'œd(d)„Zedd*œd+d,„ƒZd&d*œd-d.„Zd/d&d0œd1d2„Zed3d3d3d3d3d4œddd5d dd/d6d7œd8d9„ƒZed/d6d0œd:d9„ƒZd/d6d0œd;d9„Zdd*œd<d=„Zedd*œd>d?„ƒZedd*œd@dA„ƒZe ¡Zdd*œdBdC„Zd[d    d&dEœdFdG„Zejd\dHdIdJœdKdL„ƒZejdId*œdMdN„ƒZ dOdPd/d&dQœdRdS„Z!dTd*œdUdV„Z"dWd*œdXdY„Z#dS)]rNa‚
    Connects a :class:`~sqlalchemy.pool.Pool` and
    :class:`~sqlalchemy.engine.interfaces.Dialect` together to provide a
    source of database connectivity and behavior.
 
    An :class:`_engine.Engine` object is instantiated publicly using the
    :func:`~sqlalchemy.create_engine` function.
 
    .. seealso::
 
        :doc:`/core/engines`
 
        :ref:`connections_toplevel`
 
    rGrHr–r r+rKFrOrRzType[Connection]Ú_connection_clszsqlalchemy.engine.Enginerpr_Ú
_is_futureNr€rƒzType[OptionEngine]Ú _option_clsr.rUr5r;r1Úurlr&éôr„zOptional[_EchoFlagType]r—zOptional[Mapping[str, Any]])r;rUrÚ logging_nameÚechoÚquery_cache_sizer™r&c        Csl||_||_||_|r||_||_||_|dkrDtj||jd|_    nd|_    t
j ||d|rh|j f|ŽdS)Nr)Z
size_alert©Zechoflag) r;rrUrrr&r ZLRUCacheÚ_lru_size_alertr rÚinstance_loggerÚupdate_execution_options)    r`r;rUrrrr‘r™r&rbrbrcrdx s  ÿ
zEngine.__init__zutil.LRUCache[Any, Any]rq)ÚcacherfcCs"| ¡r|j dt|ƒ|j¡dS)NziCompiled cache size pruning from %d items to %d.  Increase cache size to reduce the frequency of pruning.)r]ryrzrÚcapacity)r`r–rbrbrcr“” s üzEngine._lru_size_alertrecCs|S)z§Returns this :class:`.Engine`.
 
        Used for legacy schemes that accept :class:`.Connection` /
        :class:`.Engine` objects within the same variable.
 
        rbrnrbrbrcrP sz Engine.enginecCs|jr|j ¡dS)aˆClear the compiled cache associated with the dialect.
 
        This applies **only** to the built-in cache that is established
        via the :paramref:`_engine.create_engine.query_cache_size` parameter.
        It will not impact any dictionary caches that were passed via the
        :paramref:`.Connection.execution_options.query_cache` parameter.
 
        .. versionadded:: 1.4
 
        N)r ÚclearrnrbrbrcÚclear_compiled_cache§ s zEngine.clear_compiled_cacherršcKs.|j ||¡|j |¡|_|j ||¡dS)aþUpdate the default execution_options dictionary
        of this :class:`_engine.Engine`.
 
        The given keys/values in \**opt are added to the
        default execution options that will be used for
        all connections.  The initial contents of this dictionary
        can be sent via the ``execution_options`` parameter
        to :func:`_sa.create_engine`.
 
        .. seealso::
 
            :meth:`_engine.Connection.execution_options`
 
            :meth:`_engine.Engine.execution_options`
 
        N)rHZset_engine_execution_optionsrKrœrUr›rbrbrcr•µ szEngine.update_execution_options.)rrgrr•rrÚ OptionEngine)rrgrr•rr˜rfcKsdSrˆrb)r`rrgrr•rr˜rbrbrcr™Ê s zEngine.execution_optionscKsdSrˆrbr›rbrbrcr™× scKs | ||¡S)a*Return a new :class:`_engine.Engine` that will provide
        :class:`_engine.Connection` objects with the given execution options.
 
        The returned :class:`_engine.Engine` remains related to the original
        :class:`_engine.Engine` in that it shares the same connection pool and
        other state:
 
        * The :class:`_pool.Pool` used by the new :class:`_engine.Engine`
          is the
          same instance.  The :meth:`_engine.Engine.dispose`
          method will replace
          the connection pool instance for the parent engine as well
          as this one.
        * Event listeners are "cascaded" - meaning, the new
          :class:`_engine.Engine`
          inherits the events of the parent, and new events can be associated
          with the new :class:`_engine.Engine` individually.
        * The logging configuration and logging_name is copied from the parent
          :class:`_engine.Engine`.
 
        The intent of the :meth:`_engine.Engine.execution_options` method is
        to implement schemes where multiple :class:`_engine.Engine`
        objects refer to the same connection pool, but are differentiated
        by options that affect some execution-level behavior for each
        engine.    One such example is breaking into separate "reader" and
        "writer" :class:`_engine.Engine` instances, where one
        :class:`_engine.Engine`
        has a lower :term:`isolation level` setting configured or is even
        transaction-disabled using "autocommit".  An example of this
        configuration is at :ref:`dbapi_autocommit_multiple`.
 
        Another example is one that
        uses a custom option ``shard_id`` which is consumed by an event
        to change the current schema on a database connection::
 
            from sqlalchemy import event
            from sqlalchemy.engine import Engine
 
            primary_engine = create_engine("mysql+mysqldb://")
            shard1 = primary_engine.execution_options(shard_id="shard1")
            shard2 = primary_engine.execution_options(shard_id="shard2")
 
            shards = {"default": "base", "shard_1": "db1", "shard_2": "db2"}
 
            @event.listens_for(Engine, "before_cursor_execute")
            def _switch_shard(conn, cursor, stmt,
                    params, context, executemany):
                shard_id = conn.get_execution_options().get('shard_id', "default")
                current_shard = conn.info.get("current_shard", None)
 
                if current_shard != shard_id:
                    cursor.execute("use %s" % shards[shard_id])
                    conn.info["current_shard"] = shard_id
 
        The above recipe illustrates two :class:`_engine.Engine` objects that
        will each serve as factories for :class:`_engine.Connection` objects
        that have pre-established "shard_id" execution options present. A
        :meth:`_events.ConnectionEvents.before_cursor_execute` event handler
        then interprets this execution option to emit a MySQL ``use`` statement
        to switch databases before a statement execution, while at the same
        time keeping track of which database we've established using the
        :attr:`_engine.Connection.info` dictionary.
 
        .. seealso::
 
            :meth:`_engine.Connection.execution_options`
            - update execution options
            on a :class:`_engine.Connection` object.
 
            :meth:`_engine.Engine.update_execution_options`
            - update the execution
            options for a given :class:`_engine.Engine` in place.
 
            :meth:`_engine.Engine.get_execution_options`
 
 
        )rŒr›rbrbrcr™Û sNcCs|jS)z³Get the non-SQL options which will take effect during execution.
 
        .. versionadded: 1.3
 
        .. seealso::
 
            :meth:`_engine.Engine.execution_options`
        rmrnrbrbrcr+ s    zEngine.get_execution_optionscCs|jjS)zsString name of the :class:`~sqlalchemy.engine.interfaces.Dialect`
        in use by this :class:`Engine`.
 
        )rUr†rnrbrbrcr†6 sz Engine.namecCs|jjS)zsDriver name of the :class:`~sqlalchemy.engine.interfaces.Dialect`
        in use by this :class:`Engine`.
 
        )rUÚdriverrnrbrbrcr›? sz Engine.drivercCs d|jfS)Nz
Engine(%r))rrnrbrbrcÚ__repr__J szEngine.__repr__T)rrfcCs*|r|j ¡|j ¡|_|j |¡dS)aDispose of the connection pool used by this
        :class:`_engine.Engine`.
 
        A new connection pool is created immediately after the old one has been
        disposed. The previous connection pool is disposed either actively, by
        closing out all currently checked-in connections in that pool, or
        passively, by losing references to it but otherwise not closing any
        connections. The latter strategy is more appropriate for an initializer
        in a forked Python process.
 
        :param close: if left at its default of ``True``, has the
         effect of fully closing all **currently checked in**
         database connections.  Connections that are still checked out
         will **not** be closed, however they will no longer be associated
         with this :class:`_engine.Engine`,
         so when they are closed individually, eventually the
         :class:`_pool.Pool` which they are associated with will
         be garbage collected and they will be closed out fully, if
         not already closed on checkin.
 
         If set to ``False``, the previous connection pool is de-referenced,
         and otherwise not touched in any way.
 
        .. versionadded:: 1.4.33  Added the :paramref:`.Engine.dispose.close`
            parameter to allow the replacement of a connection pool in a child
            process without interfering with the connections used by the parent
            process.
 
 
        .. seealso::
 
            :ref:`engine_disposal`
 
            :ref:`pooling_multiprocessing`
 
        N)r;ÚdisposeZrecreaterHZengine_disposed)r`rrbrbrcrM s%
 zEngine.disposerdzIterator[Connection])rQrfc    cs.|dkr$| ¡ }|VW5QRXn|VdSrˆ)Úconnect)r`rQrärbrbrcÚ_optional_conn_ctx_managerw s
z!Engine._optional_conn_ctx_managerc
cs2| ¡ }| ¡ |VW5QRXW5QRXdS)a7Return a context manager delivering a :class:`_engine.Connection`
        with a :class:`.Transaction` established.
 
        E.g.::
 
            with engine.begin() as conn:
                conn.execute(
                    text("insert into table (x, y, z) values (1, 2, 3)")
                )
                conn.execute(text("my_special_procedure(5)"))
 
        Upon successful operation, the :class:`.Transaction`
        is committed.  If an error is raised, the :class:`.Transaction`
        is rolled back.
 
        .. seealso::
 
            :meth:`_engine.Engine.connect` - procure a
            :class:`_engine.Connection` from
            an :class:`_engine.Engine`.
 
            :meth:`_engine.Connection.begin` - start a :class:`.Transaction`
            for a particular :class:`_engine.Connection`.
 
        N)ržr¸)r`rärbrbrcr¸ s
 
z Engine.beginrTr@rUc    Ks(| ¡}|j||f|ŽW5QRXdSrˆ)r¸rY)r`rVrWrXrärbrbrcrY  s
zEngine._run_ddl_visitorrFcCs
| |¡S)a<Return a new :class:`_engine.Connection` object.
 
        The :class:`_engine.Connection` acts as a Python context manager, so
        the typical use of this method looks like::
 
            with engine.connect() as connection:
                connection.execute(text("insert into table values ('foo')"))
                connection.commit()
 
        Where above, after the block is completed, the connection is "closed"
        and its underlying DBAPI resources are returned to the connection pool.
        This also has the effect of rolling back any transaction that
        was explicitly begun or was begun via autobegin, and will
        emit the :meth:`_events.ConnectionEvents.rollback` event if one was
        started and is still in progress.
 
        .. seealso::
 
            :meth:`_engine.Engine.begin`
 
        )rŠrnrbrbrcrž© szEngine.connectr6cCs
|j ¡S)aCReturn a "raw" DBAPI connection from the connection pool.
 
        The returned object is a proxied version of the DBAPI
        connection object used by the underlying driver in use.
        The object will have all the same behavior as the real DBAPI
        connection, except that its ``close()`` method will result in the
        connection being returned to the pool, rather than being closed
        for real.
 
        This method provides direct DBAPI connection access for
        special situations when the API provided by
        :class:`_engine.Connection`
        is not needed.   When a :class:`_engine.Connection` object is already
        present, the DBAPI connection is available using
        the :attr:`_engine.Connection.connection` accessor.
 
        .. seealso::
 
            :ref:`dbapi_connections`
 
        )r;ržrnrbrbrcrV szEngine.raw_connection)NNrŽNF)T)N)$rZr[r\r]r^rDrKrRrFrŠr_r‹rƒrdr“r`rPr™r•r r™rr†r›rZ echo_propertyrrœrÚ
contextlibÚcontextmanagerrŸr¸rYržrVrbrbrbrcrNS sf
      ÷        ù  P *ÿ        rNc@sÀeZdZUdZded<ded<ded<ded    <d
ed <d ed <ded<dddœdd„Zdddœdd„Zejs¼e    ddœdd„ƒZ
e
j dddœdd„ƒZ
e    d dœdd „ƒZ e j d dd!œd"d „ƒZ d#S)$ÚOptionEngineMixinFrGrHr–r r.rUr5r;r1rrOr&zlog.echo_propertyrrNr-)Úproxiedr™cCsn||_|j|_|j|_|j|_|j|_|j|_|j|_tj||jd|j     
|j    ¡|_    |j |_ |j f|ŽdS)Nr’) Ú_proxiedrrUrrr r&rr”rHr_rKr•)r`r£r™rbrbrcrdæ szOptionEngineMixin.__init__rrqršcKs
tƒ‚dSrˆrir›rbrbrcr• sz*OptionEngineMixin.update_execution_optionsrecCs|jjSrˆ©r¤r;rnrbrbrcr;     szOptionEngineMixin.pool)r;rfcCs ||j_dSrˆr¥)r`r;rbrbrcr; scCs|jjp|j dd¡S)NrRF)r¤rRÚ__dict__r‚rnrbrbrcrR sÿzOptionEngineMixin._has_events)r‹rfcCs||jd<dS)NrR)r¦)r`r‹rbrbrcrR sN) rZr[r\Z_sa_propagate_class_eventsr^rdr•ÚtypingÚ TYPE_CHECKINGr`r;ÚsetterrRrbrbrbrcr¢Û s&
r¢c@seZdZdddœdd„ZdS)ršrrqršcKstj|f|ŽdSrˆ)rNr•r›rbrbrcr• sz%OptionEngine.update_execution_optionsN)rZr[r\r•rbrbrbrcrš srš)cr]Ú
__future__rr r@r§rrrrrrr    r
r r r rrrZ
interfacesrrrrrrrr rrrr°rrrZsqlr!r'r¨r"r#r$r%r&r'r(r)r*r+r,r-r.r/Z
reflectionr0rr1Úeventr2r3r;r4r5r6r7Z sql._typingr8Z sql.compilerr9Zsql.ddlr:r;r<Z sql.functionsr=Z
sql.schemar>r?r@Zsql.selectablerArBÚ
EMPTY_DICTrDr^rEZ InspectablerFrHrfrºr»r½Z
IdentifiedrNr¢ršrŒrbrbrbrcÚ<module>sÔ                                                                I/lr)
ÿ A