cloud-sql-python-connector 1.22.0__tar.gz → 1.23.0__tar.gz

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.
Files changed (33) hide show
  1. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/PKG-INFO +10 -9
  2. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/README.md +6 -2
  3. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/cloud_sql_python_connector.egg-info/PKG-INFO +10 -9
  4. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/cloud_sql_python_connector.egg-info/SOURCES.txt +1 -0
  5. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/cloud_sql_python_connector.egg-info/requires.txt +1 -3
  6. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/client.py +15 -3
  7. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/connection_info.py +8 -1
  8. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/connector.py +349 -134
  9. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/enums.py +3 -0
  10. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/exceptions.py +33 -0
  11. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/instance.py +2 -2
  12. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/lazy.py +2 -2
  13. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/monitored_cache.py +10 -9
  14. cloud_sql_python_connector-1.23.0/google/cloud/sql/connector/psycopg.py +323 -0
  15. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/refresh_utils.py +4 -3
  16. cloud_sql_python_connector-1.23.0/google/cloud/sql/connector/sqldata_client.py +654 -0
  17. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/version.py +1 -1
  18. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/pyproject.toml +19 -7
  19. cloud_sql_python_connector-1.22.0/google/cloud/sql/connector/psycopg.py +0 -235
  20. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/LICENSE +0 -0
  21. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/cloud_sql_python_connector.egg-info/dependency_links.txt +0 -0
  22. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/cloud_sql_python_connector.egg-info/top_level.txt +0 -0
  23. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/__init__.py +0 -0
  24. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/asyncpg.py +0 -0
  25. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/connection_name.py +0 -0
  26. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/pg8000.py +0 -0
  27. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/py.typed +0 -0
  28. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/pymysql.py +0 -0
  29. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/pytds.py +0 -0
  30. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/rate_limiter.py +0 -0
  31. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/resolver.py +0 -0
  32. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/utils.py +0 -0
  33. {cloud_sql_python_connector-1.22.0 → cloud_sql_python_connector-1.23.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloud-sql-python-connector
3
- Version: 1.22.0
3
+ Version: 1.23.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
@@ -12,13 +12,12 @@ Classifier: Development Status :: 5 - Production/Stable
12
12
  Classifier: Intended Audience :: Developers
13
13
  Classifier: Programming Language :: Python
14
14
  Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.9
16
- Classifier: Programming Language :: Python :: 3.10
17
15
  Classifier: Programming Language :: Python :: 3.11
18
16
  Classifier: Programming Language :: Python :: 3.12
19
17
  Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
20
19
  Classifier: Operating System :: OS Independent
21
- Requires-Python: >=3.9
20
+ Requires-Python: >=3.11
22
21
  Description-Content-Type: text/markdown
23
22
  License-File: LICENSE
24
23
  Requires-Dist: aiohttp
@@ -26,9 +25,7 @@ Requires-Dist: cryptography>=42.0.0
26
25
  Requires-Dist: dnspython>=2.0.0
27
26
  Requires-Dist: Requests
28
27
  Requires-Dist: google-auth>=2.28.0
29
- Requires-Dist: grpcio
30
- Requires-Dist: protobuf
31
- Requires-Dist: googleapis-common-protos
28
+ Requires-Dist: google-cloud-sql>=0.1.1
32
29
  Provides-Extra: pymysql
33
30
  Requires-Dist: PyMySQL>=1.1.0; extra == "pymysql"
34
31
  Provides-Extra: pg8000
@@ -244,7 +241,7 @@ from google.cloud.sql.connector import Connector
244
241
 
245
242
  # Note: all parameters below are optional
246
243
  connector = Connector(
247
- ip_type="public", # can also be "private" or "psc"
244
+ ip_type="public", # can also be "private", "psc", or "sql_data"
248
245
  enable_iam_auth=False,
249
246
  timeout=30,
250
247
  credentials=custom_creds, # google.auth.credentials.Credentials
@@ -322,7 +319,11 @@ with, set the `ip_type` keyword argument when initializing a `Connector()` or wh
322
319
  calling `connector.connect()`.
323
320
 
324
321
  Possible values for `ip_type` are `"public"` (default value),
325
- `"private"`, and `"psc"`.
322
+ `"private"`, `"psc"`, and `"sql_data"`.
323
+
324
+ > [!NOTE]
325
+ >
326
+ > Usage of the `asyncpg` driver does not currently support `ip_type="sql_data"` (`IPTypes.SQL_DATA`).
326
327
 
327
328
  Example:
328
329
 
@@ -201,7 +201,7 @@ from google.cloud.sql.connector import Connector
201
201
 
202
202
  # Note: all parameters below are optional
203
203
  connector = Connector(
204
- ip_type="public", # can also be "private" or "psc"
204
+ ip_type="public", # can also be "private", "psc", or "sql_data"
205
205
  enable_iam_auth=False,
206
206
  timeout=30,
207
207
  credentials=custom_creds, # google.auth.credentials.Credentials
@@ -279,7 +279,11 @@ with, set the `ip_type` keyword argument when initializing a `Connector()` or wh
279
279
  calling `connector.connect()`.
280
280
 
281
281
  Possible values for `ip_type` are `"public"` (default value),
282
- `"private"`, and `"psc"`.
282
+ `"private"`, `"psc"`, and `"sql_data"`.
283
+
284
+ > [!NOTE]
285
+ >
286
+ > Usage of the `asyncpg` driver does not currently support `ip_type="sql_data"` (`IPTypes.SQL_DATA`).
283
287
 
284
288
  Example:
285
289
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cloud-sql-python-connector
3
- Version: 1.22.0
3
+ Version: 1.23.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
@@ -12,13 +12,12 @@ Classifier: Development Status :: 5 - Production/Stable
12
12
  Classifier: Intended Audience :: Developers
13
13
  Classifier: Programming Language :: Python
14
14
  Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.9
16
- Classifier: Programming Language :: Python :: 3.10
17
15
  Classifier: Programming Language :: Python :: 3.11
18
16
  Classifier: Programming Language :: Python :: 3.12
19
17
  Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
20
19
  Classifier: Operating System :: OS Independent
21
- Requires-Python: >=3.9
20
+ Requires-Python: >=3.11
22
21
  Description-Content-Type: text/markdown
23
22
  License-File: LICENSE
24
23
  Requires-Dist: aiohttp
@@ -26,9 +25,7 @@ Requires-Dist: cryptography>=42.0.0
26
25
  Requires-Dist: dnspython>=2.0.0
27
26
  Requires-Dist: Requests
28
27
  Requires-Dist: google-auth>=2.28.0
29
- Requires-Dist: grpcio
30
- Requires-Dist: protobuf
31
- Requires-Dist: googleapis-common-protos
28
+ Requires-Dist: google-cloud-sql>=0.1.1
32
29
  Provides-Extra: pymysql
33
30
  Requires-Dist: PyMySQL>=1.1.0; extra == "pymysql"
34
31
  Provides-Extra: pg8000
@@ -244,7 +241,7 @@ from google.cloud.sql.connector import Connector
244
241
 
245
242
  # Note: all parameters below are optional
246
243
  connector = Connector(
247
- ip_type="public", # can also be "private" or "psc"
244
+ ip_type="public", # can also be "private", "psc", or "sql_data"
248
245
  enable_iam_auth=False,
249
246
  timeout=30,
250
247
  credentials=custom_creds, # google.auth.credentials.Credentials
@@ -322,7 +319,11 @@ with, set the `ip_type` keyword argument when initializing a `Connector()` or wh
322
319
  calling `connector.connect()`.
323
320
 
324
321
  Possible values for `ip_type` are `"public"` (default value),
325
- `"private"`, and `"psc"`.
322
+ `"private"`, `"psc"`, and `"sql_data"`.
323
+
324
+ > [!NOTE]
325
+ >
326
+ > Usage of the `asyncpg` driver does not currently support `ip_type="sql_data"` (`IPTypes.SQL_DATA`).
326
327
 
327
328
  Example:
328
329
 
@@ -25,5 +25,6 @@ google/cloud/sql/connector/pytds.py
25
25
  google/cloud/sql/connector/rate_limiter.py
26
26
  google/cloud/sql/connector/refresh_utils.py
27
27
  google/cloud/sql/connector/resolver.py
28
+ google/cloud/sql/connector/sqldata_client.py
28
29
  google/cloud/sql/connector/utils.py
29
30
  google/cloud/sql/connector/version.py
@@ -3,9 +3,7 @@ cryptography>=42.0.0
3
3
  dnspython>=2.0.0
4
4
  Requests
5
5
  google-auth>=2.28.0
6
- grpcio
7
- protobuf
8
- googleapis-common-protos
6
+ google-cloud-sql>=0.1.1
9
7
 
10
8
  [asyncpg]
11
9
  asyncpg>=0.30.0
@@ -173,9 +173,13 @@ class CloudSQLClient:
173
173
  if psc_dns_names:
174
174
  ip_addresses["PSC"] = psc_dns_names
175
175
 
176
+ server_ca_cert = None
177
+ if "serverCaCert" in ret_dict and "cert" in ret_dict["serverCaCert"]:
178
+ server_ca_cert = ret_dict["serverCaCert"]["cert"]
179
+
176
180
  return {
177
181
  "ip_addresses": ip_addresses,
178
- "server_ca_cert": ret_dict["serverCaCert"]["cert"],
182
+ "server_ca_cert": server_ca_cert,
179
183
  "database_version": ret_dict["databaseVersion"],
180
184
  }
181
185
 
@@ -271,7 +275,15 @@ class CloudSQLClient:
271
275
  finally:
272
276
  resp.raise_for_status()
273
277
 
274
- ephemeral_cert: str = ret_dict["ephemeralCert"]["cert"]
278
+ try:
279
+ ephemeral_cert: str = ret_dict["ephemeralCert"]["cert"]
280
+ except KeyError as e:
281
+ logger.error(
282
+ "KeyError in _get_ephemeral parsing generateEphemeralCert: %s. Response dict: %s",
283
+ e,
284
+ ret_dict,
285
+ )
286
+ raise
275
287
 
276
288
  # decode cert to read expiration
277
289
  x509 = load_pem_x509_certificate(
@@ -285,7 +297,7 @@ class CloudSQLClient:
285
297
  # google.auth library strips timezone info for backwards compatibality
286
298
  # reasons with Python 2. Add it back to allow timezone aware datetimes.
287
299
  # Ref: https://github.com/googleapis/google-auth-library-python/blob/49a5ff7411a2ae4d32a7d11700f9f961c55406a9/google/auth/_helpers.py#L93-L99
288
- token_expiration = token_expiration.replace(tzinfo=datetime.timezone.utc)
300
+ token_expiration = token_expiration.replace(tzinfo=datetime.UTC)
289
301
 
290
302
  expiration = min(expiration, token_expiration)
291
303
  return ephemeral_cert, expiration
@@ -21,6 +21,7 @@ import ssl
21
21
  from typing import Any, TYPE_CHECKING
22
22
 
23
23
  from google.cloud.sql.connector.connection_name import ConnectionName
24
+ from google.cloud.sql.connector.exceptions import CloudSQLConnectionError
24
25
  from google.cloud.sql.connector.exceptions import CloudSQLIPTypeError
25
26
  from google.cloud.sql.connector.exceptions import TLSVersionError
26
27
  from google.cloud.sql.connector.utils import AsyncTemporaryDirectory
@@ -62,7 +63,7 @@ class ConnectionInfo:
62
63
 
63
64
  conn_name: ConnectionName
64
65
  client_cert: str
65
- server_ca_cert: str
66
+ server_ca_cert: str | None
66
67
  private_key: bytes
67
68
  ip_addrs: dict[str, Any]
68
69
  database_version: str
@@ -78,6 +79,12 @@ class ConnectionInfo:
78
79
  # if SSL context is cached, use it
79
80
  if self.context is not None:
80
81
  return self.context
82
+
83
+ if self.server_ca_cert is None:
84
+ raise CloudSQLConnectionError(
85
+ "Cannot create SSL context: server CA certificate is missing."
86
+ )
87
+
81
88
  context = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
82
89
 
83
90
  # update ssl.PROTOCOL_TLS_CLIENT default