cloud-sql-python-connector 1.18.4__py3-none-any.whl → 1.19.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloud-sql-python-connector
3
- Version: 1.18.4
3
+ Version: 1.19.0
4
4
  Summary: Google Cloud SQL Python Connector library
5
5
  Author-email: Google LLC <googleapis-packages@google.com>
6
6
  License-Expression: Apache-2.0
@@ -387,14 +387,27 @@ conn = connector.connect(
387
387
  )
388
388
  ```
389
389
 
390
- ### Using DNS domain names to identify instances
390
+ ### Using Advanced Disaster Recovery and DNS domain names to identify instances
391
391
 
392
- The connector can be configured to use DNS to look up an instance. This would
393
- allow you to configure your application to connect to a database instance, and
394
- centrally configure which instance in your DNS zone.
392
+ The connector can be configured to use DNS to look up an instance.
393
+ Use a DNS name managed by Cloud SQL [Advanced Disaster Recovery](https://docs.cloud.google.com/sql/docs/mysql/use-advanced-disaster-recovery),
394
+ or a domain name that you manage.
395
+
396
+ #### Using Advanced Recovery Write Endpoint DNS Name
397
+
398
+ [Advanced Disaster Recovery](https://docs.cloud.google.com/sql/docs/mysql/use-advanced-disaster-recovery)
399
+ creates geographically distributed replicas of your Cloud SQL database instance. When you perform
400
+ switchover or failover on the database instance, the connector will gracefully disconnect from the
401
+ old primary instance and reconnect to the new primary instance.
402
+
403
+ Follow the instructions in [Connect using Write Endpoint](https://docs.cloud.google.com/sql/docs/mysql/connect-to-instance-using-write-endpoint)
404
+ to get the write endpoint DNS name for your primary instance. Then, use this write endpoint DNS
405
+ name to configure the connector.
395
406
 
396
407
  #### Configure your DNS Records
397
408
 
409
+ The connector may be configured to use DNS that you define as well.
410
+
398
411
  Add a DNS TXT record for the Cloud SQL instance to a **private** DNS server
399
412
  or a private Google Cloud DNS Zone used by your application.
400
413
 
@@ -605,7 +618,7 @@ from google.cloud.sql.connector import Connector, create_async_connector
605
618
 
606
619
  async def main():
607
620
  # initialize Connector object for connections to Cloud SQL
608
- connector = create_async_connector()
621
+ connector = await create_async_connector()
609
622
 
610
623
  # creation function to generate asyncpg connections as the 'connect' arg
611
624
  async def getconn(instance_connection_name, **kwargs) -> asyncpg.Connection:
@@ -1,10 +1,10 @@
1
- cloud_sql_python_connector-1.18.4.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
1
+ cloud_sql_python_connector-1.19.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
2
2
  google/cloud/sql/connector/__init__.py,sha256=w6w35V-m2QlpcL-ShKd2BvNF-xXOwJ2FoidE7npPE7c,1148
3
3
  google/cloud/sql/connector/asyncpg.py,sha256=v4ohOnSYjHTOvJPhTE761xP1KKo4FUJQW_WAnNW_2g4,1918
4
- google/cloud/sql/connector/client.py,sha256=QhxoCLn1KFKpBsLKU46GPvWI7GYuSo0oPXm_QGI-7fI,13076
4
+ google/cloud/sql/connector/client.py,sha256=uVOMnRe1AxiSh6BnK4-SuSYrRID_jnm7SgMMN6s5jp4,13076
5
5
  google/cloud/sql/connector/connection_info.py,sha256=BSuW-ovtEUYTIvDzQkaE3GofCs3Xoi0TtztFaAq4Kvo,4868
6
6
  google/cloud/sql/connector/connection_name.py,sha256=bI4M3Qa2mtBHyD08oF41FF5W9FBOXWu4dGGg50Na_A4,2606
7
- google/cloud/sql/connector/connector.py,sha256=H2vDRZ-N8mz8oO_OnKCY-LODbsAnzaxEMGPl4zv10sc,24182
7
+ google/cloud/sql/connector/connector.py,sha256=MJFRKBhwpWtwUo7EvwFggu2X5s2d5CgQdm8ZFZtnYV4,24720
8
8
  google/cloud/sql/connector/enums.py,sha256=dVBS9eEWNrHtzze0AJlmtbdUogG3EocNWOQcI_8qPd0,2937
9
9
  google/cloud/sql/connector/exceptions.py,sha256=QdQBzZ3t1RE5V744wW4sGaucWD2cEedB-dWNCkh8SAA,1974
10
10
  google/cloud/sql/connector/instance.py,sha256=jDEQf-OXFzqKO9a4bnzRQ0qUyO3_xKuiEIRWc_7wpyE,8694
@@ -15,11 +15,11 @@ google/cloud/sql/connector/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
15
15
  google/cloud/sql/connector/pymysql.py,sha256=PrTQ1lB5EWAcN4BPX_5hb-WerncS4X76bBk4y0es0ks,1948
16
16
  google/cloud/sql/connector/pytds.py,sha256=KZxmJQQG9XfmsmUoEGX7RpMirWdoreJ2-_FuHO6Td-s,2280
17
17
  google/cloud/sql/connector/rate_limiter.py,sha256=zqZ9pVXHan4LWoGT8Bq6U3HpZcrdzKhlXVYwsX3ftA0,2928
18
- google/cloud/sql/connector/refresh_utils.py,sha256=fVyydw984S1UBHv3qY9ZbCZCagA-Wd25RLA5eKxMCLk,5152
18
+ google/cloud/sql/connector/refresh_utils.py,sha256=jaYLHrKlJtqeZBM8gOrZtI-6mbh6-1PTi8o0aFGH5Yo,5151
19
19
  google/cloud/sql/connector/resolver.py,sha256=DUU7swlBjMJjlDqa_M4XtIctPiJBnz-OusFUk5GLc1Y,3290
20
20
  google/cloud/sql/connector/utils.py,sha256=AA_oBBxRuULb7-hHHK8HQJU5fttzBpzdIZwMNZ5kNCM,3473
21
- google/cloud/sql/connector/version.py,sha256=WMF0exkNMzlSFf4OUkUILFLiPsGLztn38GPenxqW684,598
22
- cloud_sql_python_connector-1.18.4.dist-info/METADATA,sha256=nuR7T_uxKLpVmugsXimXnBFbEJOmyisJSqbP_10Ngys,30340
23
- cloud_sql_python_connector-1.18.4.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
- cloud_sql_python_connector-1.18.4.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
25
- cloud_sql_python_connector-1.18.4.dist-info/RECORD,,
21
+ google/cloud/sql/connector/version.py,sha256=ubPc22if5qmly3cyzukeCbOaz4RIPktbPgIRVJToDUs,598
22
+ cloud_sql_python_connector-1.19.0.dist-info/METADATA,sha256=mvSoakX7k3zRYjqEB1z9H7wIYbAuBi9iMHwiYEi3XhE,31181
23
+ cloud_sql_python_connector-1.19.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
24
+ cloud_sql_python_connector-1.19.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
25
+ cloud_sql_python_connector-1.19.0.dist-info/RECORD,,
@@ -22,9 +22,9 @@ from typing import Any, Optional, TYPE_CHECKING
22
22
  import aiohttp
23
23
  from cryptography.hazmat.backends import default_backend
24
24
  from cryptography.x509 import load_pem_x509_certificate
25
-
26
25
  from google.auth.credentials import TokenState
27
26
  from google.auth.transport import requests
27
+
28
28
  from google.cloud.sql.connector.connection_info import ConnectionInfo
29
29
  from google.cloud.sql.connector.connection_name import ConnectionName
30
30
  from google.cloud.sql.connector.exceptions import AutoIAMAuthNotSupported
@@ -28,11 +28,13 @@ from typing import Any, Callable, Optional, Union
28
28
  import google.auth
29
29
  from google.auth.credentials import Credentials
30
30
  from google.auth.credentials import with_scopes_if_required
31
+
31
32
  import google.cloud.sql.connector.asyncpg as asyncpg
32
33
  from google.cloud.sql.connector.client import CloudSQLClient
33
34
  from google.cloud.sql.connector.enums import DriverMapping
34
35
  from google.cloud.sql.connector.enums import IPTypes
35
36
  from google.cloud.sql.connector.enums import RefreshStrategy
37
+ from google.cloud.sql.connector.exceptions import ConnectorLoopError
36
38
  from google.cloud.sql.connector.instance import RefreshAheadCache
37
39
  from google.cloud.sql.connector.lazy import LazyRefreshCache
38
40
  from google.cloud.sql.connector.monitored_cache import MonitoredCache
@@ -280,6 +282,15 @@ class Connector:
280
282
  KeyError: Unsupported database driver Must be one of pymysql, asyncpg,
281
283
  pg8000, and pytds.
282
284
  """
285
+ # check if event loop is running in current thread
286
+ if self._loop != asyncio.get_running_loop():
287
+ raise ConnectorLoopError(
288
+ "Running event loop does not match 'connector._loop'. "
289
+ "Connector.connect_async() must be called from the event loop "
290
+ "the Connector was initialized with. If you need to connect "
291
+ "across event loops, please use a new Connector object."
292
+ )
293
+
283
294
  if self._keys is None:
284
295
  self._keys = asyncio.create_task(generate_keys())
285
296
  if self._client is None:
@@ -24,7 +24,6 @@ import random
24
24
  from typing import Any, Callable
25
25
 
26
26
  import aiohttp
27
-
28
27
  from google.auth.credentials import Credentials
29
28
  from google.auth.credentials import Scoped
30
29
  import google.auth.transport.requests
@@ -12,4 +12,4 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- __version__ = "1.18.4"
15
+ __version__ = "1.19.0"