4
4
#
5
5
# This module is part of SQLAlchemy and is released under
6
6
# the MIT License: https://www.opensource.org/licenses/mit-license.php
7
+ from __future__ import annotations
8
+
9
+ from typing import Any
10
+
7
11
from . import exc as async_exc
8
12
from .base import ProxyComparable
9
13
from .base import StartableContext
@@ -72,7 +76,7 @@ class AsyncConnectable:
72
76
73
77
@util .create_proxy_methods (
74
78
Connection ,
75
- ":class:`_future .Connection`" ,
79
+ ":class:`_engine .Connection`" ,
76
80
":class:`_asyncio.AsyncConnection`" ,
77
81
classmethods = [],
78
82
methods = [],
@@ -125,6 +129,7 @@ def __init__(self, async_engine, sync_connection=None):
125
129
.. seealso::
126
130
127
131
:ref:`asyncio_events`
132
+
128
133
"""
129
134
130
135
sync_engine : Engine
@@ -137,6 +142,7 @@ def __init__(self, async_engine, sync_connection=None):
137
142
.. seealso::
138
143
139
144
:ref:`asyncio_events`
145
+
140
146
"""
141
147
142
148
@classmethod
@@ -552,10 +558,100 @@ def __await__(self):
552
558
async def __aexit__ (self , type_ , value , traceback ):
553
559
await self .close ()
554
560
561
+ # START PROXY METHODS AsyncConnection
562
+
563
+ # code within this block is **programmatically,
564
+ # statically generated** by tools/generate_proxy_methods.py
565
+
566
+ @property
567
+ def closed (self ) -> Any :
568
+ r"""Return True if this connection is closed.
569
+
570
+ .. container:: class_bases
571
+
572
+ Proxied for the :class:`_engine.Connection` class
573
+ on behalf of the :class:`_asyncio.AsyncConnection` class.
574
+
575
+ """ # noqa: E501
576
+
577
+ return self ._proxied .closed
578
+
579
+ @property
580
+ def invalidated (self ) -> Any :
581
+ r"""Return True if this connection was invalidated.
582
+
583
+ .. container:: class_bases
584
+
585
+ Proxied for the :class:`_engine.Connection` class
586
+ on behalf of the :class:`_asyncio.AsyncConnection` class.
587
+
588
+ This does not indicate whether or not the connection was
589
+ invalidated at the pool level, however
590
+
591
+
592
+ """ # noqa: E501
593
+
594
+ return self ._proxied .invalidated
595
+
596
+ @property
597
+ def dialect (self ) -> Any :
598
+ r"""Proxy for the :attr:`_engine.Connection.dialect` attribute
599
+ on behalf of the :class:`_asyncio.AsyncConnection` class.
600
+
601
+ """ # noqa: E501
602
+
603
+ return self ._proxied .dialect
604
+
605
+ @dialect .setter
606
+ def dialect (self , attr : Any ) -> None :
607
+ self ._proxied .dialect = attr
608
+
609
+ @property
610
+ def default_isolation_level (self ) -> Any :
611
+ r"""The default isolation level assigned to this
612
+ :class:`_engine.Connection`.
613
+
614
+ .. container:: class_bases
615
+
616
+ Proxied for the :class:`_engine.Connection` class
617
+ on behalf of the :class:`_asyncio.AsyncConnection` class.
618
+
619
+ This is the isolation level setting that the
620
+ :class:`_engine.Connection`
621
+ has when first procured via the :meth:`_engine.Engine.connect` method.
622
+ This level stays in place until the
623
+ :paramref:`.Connection.execution_options.isolation_level` is used
624
+ to change the setting on a per-:class:`_engine.Connection` basis.
625
+
626
+ Unlike :meth:`_engine.Connection.get_isolation_level`,
627
+ this attribute is set
628
+ ahead of time from the first connection procured by the dialect,
629
+ so SQL query is not invoked when this accessor is called.
630
+
631
+ .. versionadded:: 0.9.9
632
+
633
+ .. seealso::
634
+
635
+ :meth:`_engine.Connection.get_isolation_level`
636
+ - view current level
637
+
638
+ :paramref:`_sa.create_engine.isolation_level`
639
+ - set per :class:`_engine.Engine` isolation level
640
+
641
+ :paramref:`.Connection.execution_options.isolation_level`
642
+ - set per :class:`_engine.Connection` isolation level
643
+
644
+
645
+ """ # noqa: E501
646
+
647
+ return self ._proxied .default_isolation_level
648
+
649
+ # END PROXY METHODS AsyncConnection
650
+
555
651
556
652
@util .create_proxy_methods (
557
653
Engine ,
558
- ":class:`_future .Engine`" ,
654
+ ":class:`_engine .Engine`" ,
559
655
":class:`_asyncio.AsyncEngine`" ,
560
656
classmethods = [],
561
657
methods = [
@@ -701,6 +797,181 @@ async def dispose(self):
701
797
702
798
return await greenlet_spawn (self .sync_engine .dispose )
703
799
800
+ # START PROXY METHODS AsyncEngine
801
+
802
+ # code within this block is **programmatically,
803
+ # statically generated** by tools/generate_proxy_methods.py
804
+
805
+ def clear_compiled_cache (self ) -> None :
806
+ r"""Clear the compiled cache associated with the dialect.
807
+
808
+ .. container:: class_bases
809
+
810
+ Proxied for the :class:`_engine.Engine` class on
811
+ behalf of the :class:`_asyncio.AsyncEngine` class.
812
+
813
+ This applies **only** to the built-in cache that is established
814
+ via the :paramref:`_engine.create_engine.query_cache_size` parameter.
815
+ It will not impact any dictionary caches that were passed via the
816
+ :paramref:`.Connection.execution_options.query_cache` parameter.
817
+
818
+ .. versionadded:: 1.4
819
+
820
+
821
+ """ # noqa: E501
822
+
823
+ return self ._proxied .clear_compiled_cache ()
824
+
825
+ def update_execution_options (self , ** opt : Any ) -> None :
826
+ r"""Update the default execution_options dictionary
827
+ of this :class:`_engine.Engine`.
828
+
829
+ .. container:: class_bases
830
+
831
+ Proxied for the :class:`_engine.Engine` class on
832
+ behalf of the :class:`_asyncio.AsyncEngine` class.
833
+
834
+ The given keys/values in \**opt are added to the
835
+ default execution options that will be used for
836
+ all connections. The initial contents of this dictionary
837
+ can be sent via the ``execution_options`` parameter
838
+ to :func:`_sa.create_engine`.
839
+
840
+ .. seealso::
841
+
842
+ :meth:`_engine.Connection.execution_options`
843
+
844
+ :meth:`_engine.Engine.execution_options`
845
+
846
+
847
+ """ # noqa: E501
848
+
849
+ return self ._proxied .update_execution_options (** opt )
850
+
851
+ def get_execution_options (self ) -> _ExecuteOptions :
852
+ r"""Get the non-SQL options which will take effect during execution.
853
+
854
+ .. container:: class_bases
855
+
856
+ Proxied for the :class:`_engine.Engine` class on
857
+ behalf of the :class:`_asyncio.AsyncEngine` class.
858
+
859
+ .. versionadded: 1.3
860
+
861
+ .. seealso::
862
+
863
+ :meth:`_engine.Engine.execution_options`
864
+
865
+ """ # noqa: E501
866
+
867
+ return self ._proxied .get_execution_options ()
868
+
869
+ @property
870
+ def url (self ) -> URL :
871
+ r"""Proxy for the :attr:`_engine.Engine.url` attribute
872
+ on behalf of the :class:`_asyncio.AsyncEngine` class.
873
+
874
+ """ # noqa: E501
875
+
876
+ return self ._proxied .url
877
+
878
+ @url .setter
879
+ def url (self , attr : URL ) -> None :
880
+ self ._proxied .url = attr
881
+
882
+ @property
883
+ def pool (self ) -> Pool :
884
+ r"""Proxy for the :attr:`_engine.Engine.pool` attribute
885
+ on behalf of the :class:`_asyncio.AsyncEngine` class.
886
+
887
+ """ # noqa: E501
888
+
889
+ return self ._proxied .pool
890
+
891
+ @pool .setter
892
+ def pool (self , attr : Pool ) -> None :
893
+ self ._proxied .pool = attr
894
+
895
+ @property
896
+ def dialect (self ) -> Dialect :
897
+ r"""Proxy for the :attr:`_engine.Engine.dialect` attribute
898
+ on behalf of the :class:`_asyncio.AsyncEngine` class.
899
+
900
+ """ # noqa: E501
901
+
902
+ return self ._proxied .dialect
903
+
904
+ @dialect .setter
905
+ def dialect (self , attr : Dialect ) -> None :
906
+ self ._proxied .dialect = attr
907
+
908
+ @property
909
+ def engine (self ) -> Any :
910
+ r""".. container:: class_bases
911
+
912
+ Proxied for the :class:`_engine.Engine` class
913
+ on behalf of the :class:`_asyncio.AsyncEngine` class.
914
+
915
+
916
+ """ # noqa: E501
917
+
918
+ return self ._proxied .engine
919
+
920
+ @property
921
+ def name (self ) -> Any :
922
+ r"""String name of the :class:`~sqlalchemy.engine.interfaces.Dialect`
923
+ in use by this :class:`Engine`.
924
+
925
+ .. container:: class_bases
926
+
927
+ Proxied for the :class:`_engine.Engine` class
928
+ on behalf of the :class:`_asyncio.AsyncEngine` class.
929
+
930
+
931
+ """ # noqa: E501
932
+
933
+ return self ._proxied .name
934
+
935
+ @property
936
+ def driver (self ) -> Any :
937
+ r"""Driver name of the :class:`~sqlalchemy.engine.interfaces.Dialect`
938
+ in use by this :class:`Engine`.
939
+
940
+ .. container:: class_bases
941
+
942
+ Proxied for the :class:`_engine.Engine` class
943
+ on behalf of the :class:`_asyncio.AsyncEngine` class.
944
+
945
+
946
+ """ # noqa: E501
947
+
948
+ return self ._proxied .driver
949
+
950
+ @property
951
+ def echo (self ) -> Any :
952
+ r"""When ``True``, enable log output for this element.
953
+
954
+ .. container:: class_bases
955
+
956
+ Proxied for the :class:`_engine.Engine` class
957
+ on behalf of the :class:`_asyncio.AsyncEngine` class.
958
+
959
+ This has the effect of setting the Python logging level for the namespace
960
+ of this element's class and object reference. A value of boolean ``True``
961
+ indicates that the loglevel ``logging.INFO`` will be set for the logger,
962
+ whereas the string value ``debug`` will set the loglevel to
963
+ ``logging.DEBUG``.
964
+
965
+ """ # noqa: E501
966
+
967
+ return self ._proxied .echo
968
+
969
+ @echo .setter
970
+ def echo (self , attr : Any ) -> None :
971
+ self ._proxied .echo = attr
972
+
973
+ # END PROXY METHODS AsyncEngine
974
+
704
975
705
976
class AsyncTransaction (ProxyComparable , StartableContext ):
706
977
"""An asyncio proxy for a :class:`_engine.Transaction`."""
0 commit comments