zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
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
U
¸ý°d¹ðã@s¬ddlmZddlZddlmZddlmZddlmZddlmZddlmZddlm    Z    dd    lm
Z
dd
lm Z dd lm Z dd lm Z dd lmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlmZddlm Z ddlm!Z!ddlm"Z#dd l$m%Z%er¢dd!lm&Z&dd"lm'Z'dd#lm(Z(dd$lm)Z)dd%lm*Z*dd&lm+Z+dd'lm,Z,dd(lm-Z-dd)l.m/Z/dd*l.m0Z0dd+l1m2Z2dd,l3m4Z4dd-l3m5Z5dd.l3m6Z6dd/l7m8Z8dd0l9m:Z:dd1l;m<Z<dd2l;m=Z=dd3l;m>Z>dd4l;m?Z?dd5l;m@Z@dd6lAmBZBdd7lCmDZDdd8lEmFZFdd9lGmHZHdd:lGmIZIed;ZJed<ed=ZKe Ld>d?i¡ZMe Ld@d?i¡ZNGdAdB„dBƒZOejPe dCdDdEdFgdGdHdIdJdKdLdMdNdOdPdQg dRdSdTdUdVdWdXdYgdZGd[d\„d\ee ƒƒZQed]d\d=ZRGd^d_„d_eeRƒZSGd`da„daeeRƒZTGdbdc„dcee!edcƒZUdddedfœdgdh„ZVdidedjœdkdl„ZWeWe#_XdS)mé)Ú annotationsN)ÚAny)Ú    Awaitable)ÚCallable)ÚDict)ÚGeneric)ÚIterable)ÚIterator)ÚNoReturn)ÚOptional)Úoverload)ÚSequence)ÚTuple)ÚType)Ú TYPE_CHECKING)ÚTypeVar)ÚUnioné)Úengine)ÚReversibleProxy)ÚStartableContext)Ú_ensure_sync_result)Ú AsyncResult)ÚAsyncScalarResulté)Úutil)Úobject_session)ÚSession)ÚSessionTransaction)Ústate)Úgreenlet_spawn)ÚAsyncConnection)Ú AsyncEngine)Ú
Connection)ÚEngine)ÚResult)ÚRow)Ú
RowMapping)Ú ScalarResult)Ú_CoreAnyExecuteParams)Ú_CoreSingleExecuteParams)Ú
dispatcher)Ú_IdentityKeyType)Ú_O)ÚOrmExecuteOptionsParameter)Ú IdentityMap)Ú    ORMOption)Ú_BindArguments)Ú_EntityBindKey)Ú_PKIdentityArgument)Ú _SessionBind)Ú_SessionBindKey)Ú    _InfoType)Ú
Executable)Ú ClauseElement)ÚForUpdateParameter)ÚTypedReturnsRows)r"r!Ú_T)ÚboundZprebuffer_rowsTZstream_resultsc@s0eZdZdZGdd„dƒZeddœdd„ƒZdS)    Ú
AsyncAttrsa(Mixin class which provides an awaitable accessor for all attributes.
 
    E.g.::
 
        from __future__ import annotations
 
        from typing import List
 
        from sqlalchemy import ForeignKey
        from sqlalchemy import func
        from sqlalchemy.ext.asyncio import AsyncAttrs
        from sqlalchemy.orm import DeclarativeBase
        from sqlalchemy.orm import Mapped
        from sqlalchemy.orm import mapped_column
        from sqlalchemy.orm import relationship
 
 
        class Base(AsyncAttrs, DeclarativeBase):
            pass
 
 
        class A(Base):
            __tablename__ = "a"
 
            id: Mapped[int] = mapped_column(primary_key=True)
            data: Mapped[str]
            bs: Mapped[List[B]] = relationship()
 
 
        class B(Base):
            __tablename__ = "b"
            id: Mapped[int] = mapped_column(primary_key=True)
            a_id: Mapped[int] = mapped_column(ForeignKey("a.id"))
            data: Mapped[str]
 
    In the above example, the :class:`_asyncio.AsyncAttrs` mixin is applied to
    the declarative ``Base`` class where it takes effect for all subclasses.
    This mixin adds a single new attribute
    :attr:`_asyncio.AsyncAttrs.awaitable_attrs` to all classes, which will
    yield the value of any attribute as an awaitable. This allows attributes
    which may be subject to lazy loading or deferred / unexpiry loading to be
    accessed such that IO can still be emitted::
 
        a1 = (await async_session.scalars(select(A).where(A.id == 5))).one()
 
        # use the lazy loader on ``a1.bs`` via the ``.async_attrs``
        # interface, so that it may be awaited
        for b1 in await a1.async_attrs.bs:
            print(b1)
 
    The :attr:`_asyncio.AsyncAttrs.awaitable_attrs` performs a call against the
    attribute that is approximately equivalent to using the
    :meth:`_asyncio.AsyncSession.run_sync` method, e.g.::
 
        for b1 in await async_session.run_sync(lambda sess: a1.bs):
            print(b1)
 
    .. versionadded:: 2.0.13
 
    .. seealso::
 
        :ref:`asyncio_orm_avoid_lazyloads`
 
    c@s.eZdZdZddœdd„Zdddœd    d
„Zd S) úAsyncAttrs._AsyncAttrGetitemÚ    _instancer©r?cCs
||_dS©Nr@)Úselfr?©rCúUd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\sqlalchemy/ext/asyncio/session.pyÚ__init__’sz%AsyncAttrs._AsyncAttrGetitem.__init__ÚstrzAwaitable[Any])ÚnameÚreturncCstt|j|ƒSrA)r Úgetattrr?)rBrGrCrCrDÚ __getattr__•sz(AsyncAttrs._AsyncAttrGetitem.__getattr__N)Ú__name__Ú
__module__Ú __qualname__Ú    __slots__rErJrCrCrCrDÚ_AsyncAttrGetitemsrOr>©rHcCs
t |¡S)aNprovide a namespace of all attributes on this object wrapped
        as awaitables.
 
        e.g.::
 
 
            a1 = (await async_session.scalars(select(A).where(A.id == 5))).one()
 
            some_attribute = await a1.async_attrs.some_deferred_attribute
            some_collection = await a1.async_attrs.some_collection
 
        )r=rO©rBrCrCrDÚawaitable_attrs˜szAsyncAttrs.awaitable_attrsN)rKrLrMÚ__doc__rOÚpropertyrRrCrCrCrDr=MsA    r=z:class:`_orm.Session`z:class:`_asyncio.AsyncSession`rÚ identity_keyÚ __contains__Ú__iter__ÚaddÚadd_allÚexpireÚ
expire_allÚexpungeÚ expunge_allÚ is_modifiedÚin_transactionÚin_nested_transactionÚdirtyÚdeletedÚnewÚ identity_mapÚ    is_activeÚ    autoflushÚ no_autoflushÚinfo)Z classmethodsÚmethodsÚ
attributesc @sÎeZdZUdZdZded<dÄdddœddd    d
d œd d „ZeZded<ded<e    ddœdd„ƒZ
dÅdddddœdd„Z dd
d
d
dœdd „Z e dÆejdddd!œd"d#d$d%d&d&d'd(œd)d*„ƒZe dÇejdddd!œd+d#d$d%d&d&d,d(œd-d*„ƒZdÈejdd.œd+d#d$d%d
d,d/œd0d*„Ze dÉejdd.œd1d2d$d%d
d3d/œd4d5„ƒZe dÊejdd.œd+d2d$d%d
d
d/œd6d5„ƒZdËejdd.œd+d2d$d%d
d
d/œd7d5„Ze dÌejdd.œd1d2d$d%d
d8d/œd9d:„ƒZe dÍejdd.œd+d2d$d%d
d;d/œd<d:„ƒZdÎejdd.œd+d2d$d%d
d;d/œd=d:„Zdd>ddejd?œd@dAdBdCdd&d$dDdEœdFdG„Ze dÏejdd.œd"d#d$d%d
dHd/œdIdJ„ƒZe dÐejdd.œd+d#d$d%d
dKd/œdLdJ„ƒZdÑejdd.œd+d#d$d%d
dKd/œdMdJ„Ze dÒejdd.œd1d2d$d%d
dNd/œdOdP„ƒZe dÓejdd.œd+d2d$d%d
dQd/œdRdP„ƒZdÔejdd.œd+d2d$d%d
dQd/œdSdP„ZdddTœdUdV„ZdddWœdXdCdBdXdYœdZd[„ZdÕd\dd]œd^d_„Zd`dœdadb„Zd`dœdcdd„ZdÖdedfdgd
dhdiœdjdk„Zd
dldmœdndo„Zdpdœdqdr„Zdpdœdsdt„Zddœdudv„Zddœdwdx„Z ddœdydz„Z!ddœd{d|„Z"e    ddœd}d~„ƒZ#ddd€œdd‚„Z$d
d
d
ddƒœd„d…„Z%dd†d€œd‡dˆ„Z&ddCdTœd‰dŠ„Z'd‹dœdŒd„Z(d×ddCddŽœdd„Z)d‘dd’œd“d”„Z*dØdddd•œd–d—„Z+ddœd˜d™„Z,dddTœdšd›„Z-ddœdœd„Z.dÙddCdCdžœdŸd „Z/dCdœd¡d¢„Z0dCdœd£d¤„Z1e2d
dœd¥d¦„ƒZ3e2d
dœd§d¨„ƒZ4e2d
dœd©dª„ƒZ5e2d«dœd¬d­„ƒZ6e6j7d«dd®œd¯d­„ƒZ6e2d
dœd°d±„ƒZ8e2dCdœd²d³„ƒZ9e9j7dCdd®œd´d³„ƒZ9e2d
dœdµd¶„ƒZ:e2d
dœd·d¸„ƒZ;e    dd¹dTœdºd»„ƒZ<e    dÚdddd¼œd½d¾d&d¿d&dÀdÁœdÂdăZ=dS)ÛÚ AsyncSessionaeAsyncio version of :class:`_orm.Session`.
 
    The :class:`_asyncio.AsyncSession` is a proxy for a traditional
    :class:`_orm.Session` instance.
 
    .. versionadded:: 1.4
 
    To use an :class:`_asyncio.AsyncSession` with custom :class:`_orm.Session`
    implementations, see the
    :paramref:`_asyncio.AsyncSession.sync_session_class` parameter.
 
 
    Tzdispatcher[Session]ÚdispatchN)ÚbindsÚsync_session_classúOptional[_AsyncSessionBind]z2Optional[Dict[_SessionBindKey, _AsyncSessionBind]]zOptional[Type[Session]]r)ÚbindrmrnÚkwcKsjd}}|r||_t |¡}|r8||_dd„| ¡Dƒ}|rB||_| |jf||dœ|—Ž¡|_|_dS)aåConstruct a new :class:`_asyncio.AsyncSession`.
 
        All parameters other than ``sync_session_class`` are passed to the
        ``sync_session_class`` callable directly to instantiate a new
        :class:`_orm.Session`. Refer to :meth:`_orm.Session.__init__` for
        parameter documentation.
 
        :param sync_session_class:
          A :class:`_orm.Session` subclass or other callable which will be used
          to construct the :class:`_orm.Session` which will be proxied. This
          parameter may be used to provide custom :class:`_orm.Session`
          subclasses. Defaults to the
          :attr:`_asyncio.AsyncSession.sync_session_class` class-level
          attribute.
 
          .. versionadded:: 1.4.24
 
        NcSsi|]\}}|t |¡“qSrC)rÚ_get_sync_engine_or_connection)Ú.0ÚkeyÚbrCrCrDÚ
<dictcomp>üsÿz)AsyncSession.__init__.<locals>.<dictcomp>)rprm)    rprrrrmÚitemsrnÚ_assign_proxiedÚ sync_sessionÚ_proxied)rBrprmrnrqZ    sync_bindZ
sync_bindsrCrCrDrEÚs
þÿzAsyncSession.__init__z Type[Session]rnrryr
rPcCs tdƒ‚dS)Nztasynchronous events are not implemented at this time.  Apply synchronous listeners to the AsyncSession.sync_session.)ÚNotImplementedError)ÚclsrCrCrDÚ_no_async_engine_events%sÿz$AsyncSession._no_async_engine_eventsÚobjectzOptional[Iterable[str]]r9ÚNone)ÚinstanceÚattribute_namesÚwith_for_updaterHcÃst|jj|||dIdHdS)aµExpire and refresh the attributes on the given instance.
 
        A query will be issued to the database and all attributes will be
        refreshed with their current database value.
 
        This is the async version of the :meth:`_orm.Session.refresh` method.
        See that method for a complete description of all options.
 
        .. seealso::
 
            :meth:`_orm.Session.refresh` - main documentation for refresh
 
        )rr‚N)r ryÚrefresh)rBr€rr‚rCrCrDrƒ,s üzAsyncSession.refreshzCallable[..., Any])ÚfnÚargrqrHcÏst||jf|ž|ŽIdHS)a¤Invoke the given synchronous (i.e. not async) callable,
        passing a synchronous-style :class:`_orm.Session` as the first
        argument.
 
        This method allows traditional synchronous SQLAlchemy functions to
        run within the context of an asyncio application.
 
        E.g.::
 
            def some_business_method(session: Session, param: str) -> str:
                '''A synchronous function that does not require awaiting
 
                :param session: a SQLAlchemy Session, used synchronously
 
                :return: an optional return value is supported
 
                '''
                session.add(MyObject(param=param))
                session.flush()
                return "success"
 
 
            async def do_something_async(async_engine: AsyncEngine) -> None:
                '''an async function that uses awaiting'''
 
                with AsyncSession(async_engine) as async_session:
                    # run some_business_method() with a sync-style
                    # Session, proxied into an awaitable
                    return_code = await async_session.run_sync(some_business_method, param="param1")
                    print(return_code)
 
        This method maintains the asyncio event loop all the way through
        to the database connection by running the given callable in a
        specially instrumented greenlet.
 
        .. tip::
 
            The provided callable is invoked inline within the asyncio event
            loop, and will block on traditional IO calls.  IO within this
            callable should only call into SQLAlchemy's asyncio database
            APIs which will be properly adapted to the greenlet context.
 
        .. seealso::
 
            :class:`.AsyncAttrs`  - a mixin for ORM mapped classes that provides
            a similar feature more succinctly on a per-attribute basis
 
            :meth:`.AsyncConnection.run_sync`
 
            :ref:`session_run_sync`
        N)r ry)rBr„r…rqrCrCrDÚrun_syncGs7zAsyncSession.run_sync)Úexecution_optionsÚbind_argumentsÚ_parent_execute_stateÚ
_add_eventzTypedReturnsRows[_T]zOptional[_CoreAnyExecuteParams]r.zOptional[_BindArguments]z Optional[Any]z
Result[_T])Ú    statementÚparamsr‡rˆr‰rŠrHcÃsdSrArC©rBr‹rŒr‡rˆr‰rŠrCrCrDÚexecute€s zAsyncSession.executer7z Result[Any]cÃsdSrArCrrCrCrDrŽs )r‡rˆ)r‹rŒr‡rˆrqrHcËsP|rt |¡ t¡}nt}t|jj|f|||dœ|—ŽIdH}t||jƒIdHS)z¼Execute a statement and return a buffered
        :class:`_engine.Result` object.
 
        .. seealso::
 
            :meth:`_orm.Session.execute` - main documentation for execute
 
        ©rŒr‡rˆN)rÚ immutabledictÚunionÚ_EXECUTE_OPTIONSr ryrŽr©rBr‹rŒr‡rˆrqÚresultrCrCrDrŽšs 
ÿþûú zTypedReturnsRows[Tuple[_T]]z"Optional[_CoreSingleExecuteParams]z Optional[_T]cËsdSrArC©rBr‹rŒr‡rˆrqrCrCrDÚscalar½s
zAsyncSession.scalarcËsdSrArCr•rCrCrDr–És
cËsB|rt |¡ t¡}nt}t|jj|f|||dœ|—ŽIdH}|S)z˜Execute a statement and return a scalar result.
 
        .. seealso::
 
            :meth:`_orm.Session.scalar` - main documentation for scalar
 
        rN)rrr‘r’r ryr–r“rCrCrDr–Õs 
ÿþûú zScalarResult[_T]cËsdSrArCr•rCrCrDÚscalars÷s
zAsyncSession.scalarszScalarResult[Any]cËsdSrArCr•rCrCrDr—s
cËs(|j|f|||dœ|—ŽIdH}| ¡S)aÏExecute a statement and return scalar results.
 
        :return: a :class:`_result.ScalarResult` object
 
        .. versionadded:: 1.4.24 Added :meth:`_asyncio.AsyncSession.scalars`
 
        .. versionadded:: 1.4.26 Added
           :meth:`_asyncio.async_scoped_session.scalars`
 
        .. seealso::
 
            :meth:`_orm.Session.scalars` - main documentation for scalars
 
            :meth:`_asyncio.AsyncSession.stream_scalars` - streaming version
 
        rN)rŽr—r“rCrCrDr—sÿüû F)ÚoptionsÚpopulate_existingr‚Úidentity_tokenr‡z_EntityBindKey[_O]r3zOptional[Sequence[ORMOption]]Úboolz Optional[_O])ÚentityÚidentr˜r™r‚ršr‡rHc        Ãs$t|jj||||||dIdH}|S)zÃReturn an instance based on the given primary key identifier,
        or ``None`` if not found.
 
        .. seealso::
 
            :meth:`_orm.Session.get` - main documentation for get
 
 
        )r˜r™r‚ršN)r ryÚget)    rBrœrr˜r™r‚ršr‡Z
result_objrCrCrDrž2sù     zAsyncSession.getzAsyncResult[_T]cËsdSrArCr•rCrCrDÚstreamSs
zAsyncSession.streamzAsyncResult[Any]cËsdSrArCr•rCrCrDrŸ_s
cËsF|rt |¡ t¡}nt}t|jj|f|||dœ|—ŽIdH}t|ƒS)zbExecute a statement and return a streaming
        :class:`_asyncio.AsyncResult` object.
 
        rN)rrr‘Ú_STREAM_OPTIONSr ryrŽrr“rCrCrDrŸks 
ÿþûú zAsyncScalarResult[_T]cËsdSrArCr•rCrCrDÚstream_scalars‹s
zAsyncSession.stream_scalarszAsyncScalarResult[Any]cËsdSrArCr•rCrCrDr¡—s
cËs(|j|f|||dœ|—ŽIdH}| ¡S)aRExecute a statement and return a stream of scalar results.
 
        :return: an :class:`_asyncio.AsyncScalarResult` object
 
        .. versionadded:: 1.4.24
 
        .. seealso::
 
            :meth:`_orm.Session.scalars` - main documentation for scalars
 
            :meth:`_asyncio.AsyncSession.scalars` - non streaming version
 
        rN)rŸr—r“rCrCrDr¡£sÿüû ©r€rHcÃst|jj|ƒIdHdS)aTMark an instance as deleted.
 
        The database delete operation occurs upon ``flush()``.
 
        As this operation may need to cascade along unloaded relationships,
        it is awaitable to allow for those queries to take place.
 
        .. seealso::
 
            :meth:`_orm.Session.delete` - main documentation for delete
 
        N)r ryÚdelete©rBr€rCrCrDr£Ãs zAsyncSession.delete©Úloadr˜r-)r€r¦r˜rHcÃst|jj|||dIdHS)zÛCopy the state of a given instance into a corresponding instance
        within this :class:`_asyncio.AsyncSession`.
 
        .. seealso::
 
            :meth:`_orm.Session.merge` - main documentation for merge
 
        r¥N)r ryÚmerge)rBr€r¦r˜rCrCrDr§Òs ÿzAsyncSession.mergezOptional[Sequence[Any]])ÚobjectsrHcÃst|jj|dIdHdS)z”Flush all the object changes to the database.
 
        .. seealso::
 
            :meth:`_orm.Session.flush` - main documentation for flush
 
        )r¨N)r ryÚflush)rBr¨rCrCrDr©åszAsyncSession.flushz!Optional[AsyncSessionTransaction]cCs$|j ¡}|dk    rt |¡SdSdS)zÁReturn the current root transaction in progress, if any.
 
        :return: an :class:`_asyncio.AsyncSessionTransaction` object, or
         ``None``.
 
        .. versionadded:: 1.4.18
 
        N)ryÚget_transactionÚAsyncSessionTransactionÚ_retrieve_proxy_for_target©rBÚtransrCrCrDrªïs    
 
zAsyncSession.get_transactioncCs$|j ¡}|dk    rt |¡SdSdS)zÃReturn the current nested transaction in progress, if any.
 
        :return: an :class:`_asyncio.AsyncSessionTransaction` object, or
         ``None``.
 
        .. versionadded:: 1.4.18
 
        N)ryÚget_nested_transactionr«r¬r­rCrCrDr¯þs
 
 
z#AsyncSession.get_nested_transactionzOptional[_EntityBindKey[_O]]zOptional[ClauseElement]zOptional[_SessionBind]zUnion[Engine, Connection])ÚmapperÚclauserprqrHcKs|jjf|||dœ|—ŽS)aÛ Return a "bind" to which the synchronous proxied :class:`_orm.Session`
        is bound.
 
        Unlike the :meth:`_orm.Session.get_bind` method, this method is
        currently **not** used by this :class:`.AsyncSession` in any way
        in order to resolve engines for requests.
 
        .. note::
 
            This method proxies directly to the :meth:`_orm.Session.get_bind`
            method, however is currently **not** useful as an override target,
            in contrast to that of the :meth:`_orm.Session.get_bind` method.
            The example below illustrates how to implement custom
            :meth:`_orm.Session.get_bind` schemes that work with
            :class:`.AsyncSession` and :class:`.AsyncEngine`.
 
        The pattern introduced at :ref:`session_custom_partitioning`
        illustrates how to apply a custom bind-lookup scheme to a
        :class:`_orm.Session` given a set of :class:`_engine.Engine` objects.
        To apply a corresponding :meth:`_orm.Session.get_bind` implementation
        for use with a :class:`.AsyncSession` and :class:`.AsyncEngine`
        objects, continue to subclass :class:`_orm.Session` and apply it to
        :class:`.AsyncSession` using
        :paramref:`.AsyncSession.sync_session_class`. The inner method must
        continue to return :class:`_engine.Engine` instances, which can be
        acquired from a :class:`_asyncio.AsyncEngine` using the
        :attr:`_asyncio.AsyncEngine.sync_engine` attribute::
 
            # using example from "Custom Vertical Partitioning"
 
 
            import random
 
            from sqlalchemy.ext.asyncio import AsyncSession
            from sqlalchemy.ext.asyncio import create_async_engine
            from sqlalchemy.ext.asyncio import async_sessionmaker
            from sqlalchemy.orm import Session
 
            # construct async engines w/ async drivers
            engines = {
                'leader':create_async_engine("sqlite+aiosqlite:///leader.db"),
                'other':create_async_engine("sqlite+aiosqlite:///other.db"),
                'follower1':create_async_engine("sqlite+aiosqlite:///follower1.db"),
                'follower2':create_async_engine("sqlite+aiosqlite:///follower2.db"),
            }
 
            class RoutingSession(Session):
                def get_bind(self, mapper=None, clause=None, **kw):
                    # within get_bind(), return sync engines
                    if mapper and issubclass(mapper.class_, MyOtherClass):
                        return engines['other'].sync_engine
                    elif self._flushing or isinstance(clause, (Update, Delete)):
                        return engines['leader'].sync_engine
                    else:
                        return engines[
                            random.choice(['follower1','follower2'])
                        ].sync_engine
 
            # apply to AsyncSession using sync_session_class
            AsyncSessionMaker = async_sessionmaker(
                sync_session_class=RoutingSession
            )
 
        The :meth:`_orm.Session.get_bind` method is called in a non-asyncio,
        implicitly non-blocking context in the same manner as ORM event hooks
        and functions that are invoked via :meth:`.AsyncSession.run_sync`, so
        routines that wish to run SQL commands inside of
        :meth:`_orm.Session.get_bind` can continue to do so using
        blocking-style code, which will be translated to implicitly async calls
        at the point of invoking IO on the database drivers.
 
        )r°r±rp)ryÚget_bind)rBr°r±rprqrCrCrDr²sPÿÿzAsyncSession.get_bindr!)rqrHcËs"t|jjf|ŽIdH}tj |¡S)aReturn a :class:`_asyncio.AsyncConnection` object corresponding to
        this :class:`.Session` object's transactional state.
 
        This method may also be used to establish execution options for the
        database connection used by the current transaction.
 
        .. versionadded:: 1.4.24  Added \**kw arguments which are passed
           through to the underlying :meth:`_orm.Session.connection` method.
 
        .. seealso::
 
            :meth:`_orm.Session.connection` - main documentation for
            "connection"
 
        N)r ryÚ
connectionrr!r¬)rBrqZsync_connectionrCrCrDr³bsÿÿ
ÿzAsyncSession.connectionr«cCst|ƒS)aæReturn an :class:`_asyncio.AsyncSessionTransaction` object.
 
        The underlying :class:`_orm.Session` will perform the
        "begin" action when the :class:`_asyncio.AsyncSessionTransaction`
        object is entered::
 
            async with async_session.begin():
                # .. ORM transaction is begun
 
        Note that database IO will not normally occur when the session-level
        transaction is begun, as database transactions begin on an
        on-demand basis.  However, the begin block is async to accommodate
        for a :meth:`_orm.SessionEvents.after_transaction_create`
        event hook that may perform IO.
 
        For a general description of ORM begin, see
        :meth:`_orm.Session.begin`.
 
        ©r«rQrCrCrDÚbeginzszAsyncSession.begincCs t|ddS)a:Return an :class:`_asyncio.AsyncSessionTransaction` object
        which will begin a "nested" transaction, e.g. SAVEPOINT.
 
        Behavior is the same as that of :meth:`_asyncio.AsyncSession.begin`.
 
        For a general description of ORM begin nested, see
        :meth:`_orm.Session.begin_nested`.
 
        T)Únestedr´rQrCrCrDÚ begin_nested‘s zAsyncSession.begin_nestedcÃst|jjƒIdHdS)z-Rollback the current transaction in progress.N)r ryÚrollbackrQrCrCrDr¸žszAsyncSession.rollbackcÃst|jjƒIdHdS)z+Commit the current transaction in progress.N)r ryÚcommitrQrCrCrDr¹¢szAsyncSession.commitcÃst|jjƒIdHdS)aPClose out the transactional resources and ORM objects used by this
        :class:`_asyncio.AsyncSession`.
 
        This expunges all ORM objects associated with this
        :class:`_asyncio.AsyncSession`, ends any transaction in progress and
        :term:`releases` any :class:`_asyncio.AsyncConnection` objects which
        this :class:`_asyncio.AsyncSession` itself has checked out from
        associated :class:`_asyncio.AsyncEngine` objects. The operation then
        leaves the :class:`_asyncio.AsyncSession` in a state which it may be
        used again.
 
        .. tip::
 
            The :meth:`_asyncio.AsyncSession.close` method **does not prevent
            the Session from being used again**. The
            :class:`_asyncio.AsyncSession` itself does not actually have a
            distinct "closed" state; it merely means the
            :class:`_asyncio.AsyncSession` will release all database
            connections and ORM objects.
 
 
        .. seealso::
 
            :ref:`session_closing` - detail on the semantics of
            :meth:`_asyncio.AsyncSession.close`
 
        N)r ryÚcloserQrCrCrDrº¦szAsyncSession.closecÃst|jjƒIdHdS)z…Close this Session, using connection invalidation.
 
        For a complete description, see :meth:`_orm.Session.invalidate`.
        N)r ryÚ
invalidaterQrCrCrDr»ÄszAsyncSession.invalidatecÃst|jjƒIdHdS)z2Close all :class:`_asyncio.AsyncSession` sessions.N)r ryÚ    close_allrQrCrCrDr¼ËszAsyncSession.close_allÚ_AS)rBrHcÃs|SrArCrQrCrCrDÚ
__aenter__ÐszAsyncSession.__aenter__©Útype_ÚvalueÚ    tracebackrHcÃs"t | ¡¡}t |¡IdHdSrA)ÚasyncioÚ create_taskrºÚshield)rBrÀrÁrÂÚtaskrCrCrDÚ    __aexit__ÓszAsyncSession.__aexit__ú _AsyncSessionContextManager[_AS]cCst|ƒSrA)Ú_AsyncSessionContextManagerrQrCrCrDÚ_maker_context_manager×sz#AsyncSession._maker_context_managercCs |j |¡S)aKReturn True if the instance is associated with this session.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class on
            behalf of the :class:`_asyncio.AsyncSession` class.
 
        The instance may be pending or persistent within the Session for a
        result of True.
 
 
        )rzrVr¤rCrCrDrVßszAsyncSession.__contains__zIterator[object]cCs
|j ¡S)zøIterate over all pending or persistent instances within this
        Session.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class on
            behalf of the :class:`_asyncio.AsyncSession` class.
 
 
        )rzrWrQrCrCrDrWïs zAsyncSession.__iter__)r€Ú_warnrHcCs|jj||dS)a:Place an object into this :class:`_orm.Session`.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class on
            behalf of the :class:`_asyncio.AsyncSession` class.
 
        Objects that are in the :term:`transient` state when passed to the
        :meth:`_orm.Session.add` method will move to the
        :term:`pending` state, until the next flush, at which point they
        will move to the :term:`persistent` state.
 
        Objects that are in the :term:`detached` state when passed to the
        :meth:`_orm.Session.add` method will move to the :term:`persistent`
        state directly.
 
        If the transaction used by the :class:`_orm.Session` is rolled back,
        objects which were transient when they were passed to
        :meth:`_orm.Session.add` will be moved back to the
        :term:`transient` state, and will no longer be present within this
        :class:`_orm.Session`.
 
        .. seealso::
 
            :meth:`_orm.Session.add_all`
 
            :ref:`session_adding` - at :ref:`session_basics`
 
 
        )rË)rzrX)rBr€rËrCrCrDrXýs zAsyncSession.addzIterable[object])Ú    instancesrHcCs |j |¡S)aÓAdd the given collection of instances to this :class:`_orm.Session`.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class on
            behalf of the :class:`_asyncio.AsyncSession` class.
 
        See the documentation for :meth:`_orm.Session.add` for a general
        behavioral description.
 
        .. seealso::
 
            :meth:`_orm.Session.add`
 
            :ref:`session_adding` - at :ref:`session_basics`
 
 
        )rzrY)rBrÌrCrCrDrYszAsyncSession.add_all)r€rrHcCs|jj||dS)aaExpire the attributes on an instance.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class on
            behalf of the :class:`_asyncio.AsyncSession` class.
 
        Marks the attributes of an instance as out of date. When an expired
        attribute is next accessed, a query will be issued to the
        :class:`.Session` object's current transactional context in order to
        load all expired attributes for the given instance.   Note that
        a highly isolated transaction will return the same values as were
        previously read in that same transaction, regardless of changes
        in database state outside of that transaction.
 
        To expire all objects in the :class:`.Session` simultaneously,
        use :meth:`Session.expire_all`.
 
        The :class:`.Session` object's default behavior is to
        expire all state whenever the :meth:`Session.rollback`
        or :meth:`Session.commit` methods are called, so that new
        state can be loaded for the new transaction.   For this reason,
        calling :meth:`Session.expire` only makes sense for the specific
        case that a non-ORM SQL statement was emitted in the current
        transaction.
 
        :param instance: The instance to be refreshed.
        :param attribute_names: optional list of string attribute names
          indicating a subset of attributes to be expired.
 
        .. seealso::
 
            :ref:`session_expire` - introductory material
 
            :meth:`.Session.expire`
 
            :meth:`.Session.refresh`
 
            :meth:`_orm.Query.populate_existing`
 
 
        )r)rzrZ)rBr€rrCrCrDrZ5s.zAsyncSession.expirecCs
|j ¡S)akExpires all persistent instances within this Session.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class on
            behalf of the :class:`_asyncio.AsyncSession` class.
 
        When any attributes on a persistent instance is next accessed,
        a query will be issued using the
        :class:`.Session` object's current transactional context in order to
        load all expired attributes for the given instance.   Note that
        a highly isolated transaction will return the same values as were
        previously read in that same transaction, regardless of changes
        in database state outside of that transaction.
 
        To expire individual objects and individual attributes
        on those objects, use :meth:`Session.expire`.
 
        The :class:`.Session` object's default behavior is to
        expire all state whenever the :meth:`Session.rollback`
        or :meth:`Session.commit` methods are called, so that new
        state can be loaded for the new transaction.   For this reason,
        calling :meth:`Session.expire_all` is not usually needed,
        assuming the transaction is isolated.
 
        .. seealso::
 
            :ref:`session_expire` - introductory material
 
            :meth:`.Session.expire`
 
            :meth:`.Session.refresh`
 
            :meth:`_orm.Query.populate_existing`
 
 
        )rzr[rQrCrCrDr[es'zAsyncSession.expire_allcCs |j |¡S)adRemove the `instance` from this ``Session``.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class on
            behalf of the :class:`_asyncio.AsyncSession` class.
 
        This will free all internal references to the instance.  Cascading
        will be applied according to the *expunge* cascade rule.
 
 
        )rzr\r¤rCrCrDr\ŽszAsyncSession.expungecCs
|j ¡S)aARemove all object instances from this ``Session``.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class on
            behalf of the :class:`_asyncio.AsyncSession` class.
 
        This is equivalent to calling ``expunge(obj)`` on all objects in this
        ``Session``.
 
 
        )rzr]rQrCrCrDr]žszAsyncSession.expunge_all)r€Úinclude_collectionsrHcCs|jj||dS)aÚ
Return ``True`` if the given instance has locally
        modified attributes.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class on
            behalf of the :class:`_asyncio.AsyncSession` class.
 
        This method retrieves the history for each instrumented
        attribute on the instance and performs a comparison of the current
        value to its previously committed value, if any.
 
        It is in effect a more expensive and accurate
        version of checking for the given instance in the
        :attr:`.Session.dirty` collection; a full test for
        each attribute's net "dirty" status is performed.
 
        E.g.::
 
            return session.is_modified(someobject)
 
        A few caveats to this method apply:
 
        * Instances present in the :attr:`.Session.dirty` collection may
          report ``False`` when tested with this method.  This is because
          the object may have received change events via attribute mutation,
          thus placing it in :attr:`.Session.dirty`, but ultimately the state
          is the same as that loaded from the database, resulting in no net
          change here.
        * Scalar attributes may not have recorded the previously set
          value when a new value was applied, if the attribute was not loaded,
          or was expired, at the time the new value was received - in these
          cases, the attribute is assumed to have a change, even if there is
          ultimately no net change against its database value. SQLAlchemy in
          most cases does not need the "old" value when a set event occurs, so
          it skips the expense of a SQL call if the old value isn't present,
          based on the assumption that an UPDATE of the scalar value is
          usually needed, and in those few cases where it isn't, is less
          expensive on average than issuing a defensive SELECT.
 
          The "old" value is fetched unconditionally upon set only if the
          attribute container has the ``active_history`` flag set to ``True``.
          This flag is set typically for primary key attributes and scalar
          object references that are not a simple many-to-one.  To set this
          flag for any arbitrary mapped column, use the ``active_history``
          argument with :func:`.column_property`.
 
        :param instance: mapped instance to be tested for pending changes.
        :param include_collections: Indicates if multivalued collections
         should be included in the operation.  Setting this to ``False`` is a
         way to detect only local-column based properties (i.e. scalar columns
         or many-to-one foreign keys) that would result in an UPDATE for this
         instance upon flush.
 
 
        )rÍ)rzr^)rBr€rÍrCrCrDr^®s<ÿzAsyncSession.is_modifiedcCs
|j ¡S)aOReturn True if this :class:`_orm.Session` has begun a transaction.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class on
            behalf of the :class:`_asyncio.AsyncSession` class.
 
        .. versionadded:: 1.4
 
        .. seealso::
 
            :attr:`_orm.Session.is_active`
 
 
 
        )rzr_rQrCrCrDr_îszAsyncSession.in_transactioncCs
|j ¡S)a+Return True if this :class:`_orm.Session` has begun a nested
        transaction, e.g. SAVEPOINT.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class on
            behalf of the :class:`_asyncio.AsyncSession` class.
 
        .. versionadded:: 1.4
 
 
        )rzr`rQrCrCrDr`sz"AsyncSession.in_nested_transactioncCs|jjS)aûThe set of all persistent instances considered dirty.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class
            on behalf of the :class:`_asyncio.AsyncSession` class.
 
        E.g.::
 
            some_mapped_object in session.dirty
 
        Instances are considered dirty when they were modified but not
        deleted.
 
        Note that this 'dirty' calculation is 'optimistic'; most
        attribute-setting or collection modification operations will
        mark an instance as 'dirty' and place it in this set, even if
        there is no net change to the attribute's value.  At flush
        time, the value of each attribute is compared to its
        previously saved value, and if there's no net change, no SQL
        operation will occur (this is a more expensive operation so
        it's only done at flush time).
 
        To check if an instance has actionable net changes to its
        attributes, use the :meth:`.Session.is_modified` method.
 
 
        )rzrarQrCrCrDraszAsyncSession.dirtycCs|jjS)zîThe set of all instances marked as 'deleted' within this ``Session``
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class
            on behalf of the :class:`_asyncio.AsyncSession` class.
 
        )rzrbrQrCrCrDrb3s zAsyncSession.deletedcCs|jjS)zëThe set of all instances marked as 'new' within this ``Session``.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class
            on behalf of the :class:`_asyncio.AsyncSession` class.
 
        )rzrcrQrCrCrDrc@s zAsyncSession.newr/cCs|jjS)z‚Proxy for the :attr:`_orm.Session.identity_map` attribute
        on behalf of the :class:`_asyncio.AsyncSession` class.
 
        ©rzrdrQrCrCrDrdMszAsyncSession.identity_map)ÚattrrHcCs ||j_dSrArΩrBrÏrCrCrDrdVscCs|jjS)aÕTrue if this :class:`.Session` not in "partial rollback" state.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class
            on behalf of the :class:`_asyncio.AsyncSession` class.
 
        .. versionchanged:: 1.4 The :class:`_orm.Session` no longer begins
           a new transaction immediately, so this attribute will be False
           when the :class:`_orm.Session` is first instantiated.
 
        "partial rollback" state typically indicates that the flush process
        of the :class:`_orm.Session` has failed, and that the
        :meth:`_orm.Session.rollback` method must be emitted in order to
        fully roll back the transaction.
 
        If this :class:`_orm.Session` is not in a transaction at all, the
        :class:`_orm.Session` will autobegin when it is first used, so in this
        case :attr:`_orm.Session.is_active` will return True.
 
        Otherwise, if this :class:`_orm.Session` is within a transaction,
        and that transaction has not been rolled back internally, the
        :attr:`_orm.Session.is_active` will also return True.
 
        .. seealso::
 
            :ref:`faq_session_rollback`
 
            :meth:`_orm.Session.in_transaction`
 
 
        )rzrerQrCrCrDreZs#zAsyncSession.is_activecCs|jjS)zProxy for the :attr:`_orm.Session.autoflush` attribute
        on behalf of the :class:`_asyncio.AsyncSession` class.
 
        ©rzrfrQrCrCrDrfszAsyncSession.autoflushcCs ||j_dSrArÑrÐrCrCrDrfˆscCs|jjS)aReturn a context manager that disables autoflush.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class
            on behalf of the :class:`_asyncio.AsyncSession` class.
 
        e.g.::
 
            with session.no_autoflush:
 
                some_object = SomeClass()
                session.add(some_object)
                # won't autoflush
                some_object.related_thing = session.query(SomeRelated).first()
 
        Operations that proceed within the ``with:`` block
        will not be subject to flushes occurring upon query
        access.  This is useful when initializing a series
        of objects which involve existing database queries,
        where the uncompleted object should not yet be flushed.
 
 
        )rzrgrQrCrCrDrgŒszAsyncSession.no_autoflushcCs|jjS)a+A user-modifiable dictionary.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class
            on behalf of the :class:`_asyncio.AsyncSession` class.
 
        The initial value of this dictionary can be populated using the
        ``info`` argument to the :class:`.Session` constructor or
        :class:`.sessionmaker` constructor or factory methods.  The dictionary
        here is always local to this :class:`.Session` and can be modified
        independently of all other :class:`.Session` objects.
 
 
        )rzrhrQrCrCrDrh©szAsyncSession.infozOptional[Session]cCs
t |¡S)aReturn the :class:`.Session` to which an object belongs.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class on
            behalf of the :class:`_asyncio.AsyncSession` class.
 
        This is an alias of :func:`.object_session`.
 
 
        )rr)r|r€rCrCrDr½szAsyncSession.object_session)r€ÚrowršzOptional[Type[Any]]zUnion[Any, Tuple[Any, ...]]z%Optional[Union[Row[Any], RowMapping]]z_IdentityKeyType[Any])Úclass_rr€rÒršrHcCstj|||||dS)zûReturn an identity key.
 
        .. container:: class_bases
 
            Proxied for the :class:`_orm.Session` class on
            behalf of the :class:`_asyncio.AsyncSession` class.
 
        This is an alias of :func:`.util.identity_key`.
 
 
        )rÓrr€rÒrš)rrU)r|rÓrr€rÒršrCrCrDrUÍsûzAsyncSession.identity_key)N)NN)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)N)NNN)T)N)T)NN)>rKrLrMrSZ _is_asyncioÚ__annotations__rErrnÚ classmethodr}rƒr†r rÚ
EMPTY_DICTrŽr–r—ržrŸr¡r£r§r©rªr¯r²r³rµr·r¸r¹rºr»r¼r¾rÇrÊrVrWrXrYrZr[r\r]r^r_r`rTrarbrcrdÚsetterrerfrgrhrrUrCrCrCrDrkªsb
þû.      ü9ýø  ýø ýú#ýú ýúýú"ýú ýúýú(÷ !ýú ýúýú ýú ýúýú û
üT "ÿ0)ÿ@   $ýùrkr½c
@sÌeZdZUdZded<ed#ddddœdddddd    d
œd d „ƒZed$ddddœd ddddd    dœdd „ƒZd%eddddœdddddd    d
œdd „Zddœdd„Zd    ddœdd„Z    d    ddœdd„Z
d dœd!d"„Z dS)&Úasync_sessionmakeraëA configurable :class:`.AsyncSession` factory.
 
    The :class:`.async_sessionmaker` factory works in the same way as the
    :class:`.sessionmaker` factory, to generate new :class:`.AsyncSession`
    objects when called, creating them given
    the configurational arguments established here.
 
    e.g.::
 
        from sqlalchemy.ext.asyncio import create_async_engine
        from sqlalchemy.ext.asyncio import AsyncSession
        from sqlalchemy.ext.asyncio import async_sessionmaker
 
        async def run_some_sql(async_session: async_sessionmaker[AsyncSession]) -> None:
            async with async_session() as session:
                session.add(SomeObject(data="object"))
                session.add(SomeOtherObject(name="other object"))
                await session.commit()
 
        async def main() -> None:
            # an AsyncEngine, which the AsyncSession will use for connection
            # resources
            engine = create_async_engine('postgresql+asyncpg://scott:tiger@localhost/')
 
            # create a reusable factory for new AsyncSession instances
            async_session = async_sessionmaker(engine)
 
            await run_some_sql(async_session)
 
            await engine.dispose()
 
    The :class:`.async_sessionmaker` is useful so that different parts
    of a program can create new :class:`.AsyncSession` objects with a
    fixed configuration established up front.  Note that :class:`.AsyncSession`
    objects may also be instantiated directly when not using
    :class:`.async_sessionmaker`.
 
    .. versionadded:: 2.0  :class:`.async_sessionmaker` provides a
       :class:`.sessionmaker` class that's dedicated to the
       :class:`.AsyncSession` object, including pep-484 typing support.
 
    .. seealso::
 
        :ref:`asyncio_orm` - shows example use
 
        :class:`.sessionmaker`  - general overview of the
         :class:`.sessionmaker` architecture
 
 
        :ref:`session_getting` - introductory text on creating
        sessions using :class:`.sessionmaker`.
 
    z    Type[_AS]rÓ.)rfÚexpire_on_commitrhror›zOptional[_InfoType]r)rprÓrfrÙrhrqcKsdSrArC©rBrprÓrfrÙrhrqrCrCrDrE*s zasync_sessionmaker.__init__z"'async_sessionmaker[AsyncSession]'©rBrprfrÙrhrqcKsdSrArCrÛrCrCrDrE7s
NT)rÓrfrÙrhcKs8||d<||d<||d<|dk    r(||d<||_||_dS)aConstruct a new :class:`.async_sessionmaker`.
 
        All arguments here except for ``class_`` correspond to arguments
        accepted by :class:`.Session` directly. See the
        :meth:`.AsyncSession.__init__` docstring for more details on
        parameters.
 
 
        rprfrÙNrh)rqrÓrÚrCrCrDrECsrÈrPcCs|ƒ}| ¡S)aProduce a context manager that both provides a new
        :class:`_orm.AsyncSession` as well as a transaction that commits.
 
 
        e.g.::
 
            async def main():
                Session = async_sessionmaker(some_engine)
 
                async with Session.begin() as session:
                    session.add(some_object)
 
                # commits transaction, closes session
 
 
        )rÊ)rBÚsessionrCrCrDrµ^szasync_sessionmaker.beginr½)Úlocal_kwrHcKs\|j ¡D]D\}}|dkrBd|krB| ¡}| |d¡||d<q
| ||¡q
|jf|ŽS)a¤Produce a new :class:`.AsyncSession` object using the configuration
        established in this :class:`.async_sessionmaker`.
 
        In Python, the ``__call__`` method is invoked on an object when
        it is "called" in the same way as a function::
 
            AsyncSession = async_sessionmaker(async_engine, expire_on_commit=False)
            session = AsyncSession()  # invokes sessionmaker.__call__()
 
        rh)rqrwÚcopyÚupdateÚ
setdefaultrÓ)rBrÝÚkÚvÚdrCrCrDÚ__call__ss 
zasync_sessionmaker.__call__r)Únew_kwrHcKs|j |¡dS)zâ(Re)configure the arguments for this async_sessionmaker.
 
        e.g.::
 
            AsyncSession = async_sessionmaker(some_engine)
 
            AsyncSession.configure(bind=create_async_engine('sqlite+aiosqlite://'))
        N)rqrß)rBrårCrCrDÚ    configure‡s
zasync_sessionmaker.configurerFcCs,d|jj|jjd dd„|j ¡Dƒ¡fS)Nz%s(class_=%r, %s)z, css|]\}}d||fVqdS)z%s=%rNrC)rsrárârCrCrDÚ    <genexpr>—sz.async_sessionmaker.__repr__.<locals>.<genexpr>)Ú    __class__rKrÓÚjoinrqrwrQrCrCrDÚ__repr__“s
ýzasync_sessionmaker.__repr__).).)N) rKrLrMrSrÔr rErkrµrärærêrCrCrCrDrØñs6
6þù þú þù rØc@sReZdZUdZded<ded<ddœdd„Zdd    œd
d „Zd d d d dœdd„ZdS)rÉ)Ú async_sessionr®r½rër«r®©rëcCs
||_dSrArì)rBrërCrCrDrE¡sz$_AsyncSessionContextManager.__init__rPcÃs"|j ¡|_|j ¡IdH|jSrA)rërµr®r¾rQrCrCrDr¾¤s z&_AsyncSessionContextManager.__aenter__rrr¿cƒs8ddœ‡‡‡‡fdd„ }t |ƒ¡}t |¡IdHdS)NrrPc“s0ˆj ˆˆˆ¡IdHˆj ˆˆˆ¡IdHdSrA)r®rÇrërC©rBrÂrÀrÁrCrDÚgoªsz1_AsyncSessionContextManager.__aexit__.<locals>.go)rÃrÄrÅ)rBrÀrÁrÂrîrÆrCrírDrÇ©s z%_AsyncSessionContextManager.__aexit__N)rKrLrMrNrÔrEr¾rÇrCrCrCrDrɛs
rÉc@sšeZdZUdZdZded<ded<dddd    œd
d „Zedd œd d„ƒZdd œdd„Z    dd œdd„Z
dd œdd„Z d dddœdd„Z dddddœdd„Z dS)!r«a²A wrapper for the ORM :class:`_orm.SessionTransaction` object.
 
    This object is provided so that a transaction-holding object
    for the :meth:`_asyncio.AsyncSession.begin` may be returned.
 
    The object supports both explicit calls to
    :meth:`_asyncio.AsyncSessionTransaction.commit` and
    :meth:`_asyncio.AsyncSessionTransaction.rollback`, as well as use as an
    async context manager.
 
 
    .. versionadded:: 1.4
 
    )rÜÚsync_transactionr¶rkrÜzOptional[SessionTransaction]rïFr›)rÜr¶cCs||_||_d|_dSrA)rÜr¶rï)rBrÜr¶rCrCrDrEÊsz AsyncSessionTransaction.__init__rPcCs| ¡dk    o| ¡jSrA)Ú_sync_transactionrerQrCrCrDreÏs þz!AsyncSessionTransaction.is_activercCs|js| ¡|jSrA)rïZ_raise_for_not_startedrQrCrCrDrðÖsz)AsyncSessionTransaction._sync_transactionrcÃst| ¡jƒIdHdS)z2Roll back this :class:`_asyncio.AsyncTransaction`.N)r rðr¸rQrCrCrDr¸Ûsz AsyncSessionTransaction.rollbackcÃst| ¡jƒIdHdS)z/Commit this :class:`_asyncio.AsyncTransaction`.N)r rðr¹rQrCrCrDr¹ßszAsyncSessionTransaction.commit)Ú is_ctxmanagerrHcÃs>| t|jr|jjjn|jjjƒIdH¡|_|r:|j ¡|SrA)    rxr r¶rÜryr·rµrïÚ    __enter__)rBrñrCrCrDÚstartäsÿ ýÿ
zAsyncSessionTransaction.startrr¿cÃst| ¡j|||ƒIdHdSrA)r rðÚ__exit__)rBrÀrÁrÂrCrCrDrÇòs ÿz!AsyncSessionTransaction.__aexit__N)F)F)rKrLrMrSrNrÔrErTrerðr¸r¹rórÇrCrCrCrDr«²s
ÿr«r~zOptional[AsyncSession]r¢cCs t|ƒ}|dk    rt|ƒSdSdS)a«Return the :class:`_asyncio.AsyncSession` to which the given instance
    belongs.
 
    This function makes use of the sync-API function
    :class:`_orm.object_session` to retrieve the :class:`_orm.Session` which
    refers to the given instance, and from there links it to the original
    :class:`_asyncio.AsyncSession`.
 
    If the :class:`_asyncio.AsyncSession` has been garbage collected, the
    return value is ``None``.
 
    This functionality is also available from the
    :attr:`_orm.InstanceState.async_session` accessor.
 
    :param instance: an ORM mapped instance
    :return: an :class:`_asyncio.AsyncSession` object, or ``None``.
 
    .. versionadded:: 1.4.18
 
    N)rrë)r€rÜrCrCrDÚasync_object_sessionøsrõr)rÜrHcCstj|ddS)aReturn the :class:`_asyncio.AsyncSession` which is proxying the given
    :class:`_orm.Session` object, if any.
 
    :param session: a :class:`_orm.Session` instance.
    :return: a :class:`_asyncio.AsyncSession` instance, or ``None``.
 
    .. versionadded:: 1.4.18
 
    F)Z
regenerate)rkr¬)rÜrCrCrDrës
rë)YÚ
__future__rrÃÚtypingrrrrrrr    r
r r r rrrrrÚrÚbaserrr”rrrrZormrrrrZ_instance_stateZutil.concurrencyr r!r"r#r$r%r&r'r(Zengine.interfacesr)r*Úeventr+Z orm._typingr,r-r.Z orm.identityr/Zorm.interfacesr0Z orm.sessionr1r2r3r4r5Z sql._typingr6Zsql.baser7Z sql.elementsr8Zsql.selectabler9r:Z_AsyncSessionBindr;rr’r r=Zcreate_proxy_methodsrkr½rØrÉr«rõrëZ_async_providerrCrCrCrDÚ<module>sÜ                                                        ]õøî1 +
þF