cloud-sql-python-connector 1.22.0__py3-none-any.whl → 1.23.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.
- {cloud_sql_python_connector-1.22.0.dist-info → cloud_sql_python_connector-1.23.0.dist-info}/METADATA +10 -9
- cloud_sql_python_connector-1.23.0.dist-info/RECORD +27 -0
- google/cloud/sql/connector/client.py +15 -3
- google/cloud/sql/connector/connection_info.py +8 -1
- google/cloud/sql/connector/connector.py +349 -134
- google/cloud/sql/connector/enums.py +3 -0
- google/cloud/sql/connector/exceptions.py +33 -0
- google/cloud/sql/connector/instance.py +2 -2
- google/cloud/sql/connector/lazy.py +2 -2
- google/cloud/sql/connector/monitored_cache.py +10 -9
- google/cloud/sql/connector/psycopg.py +241 -153
- google/cloud/sql/connector/refresh_utils.py +4 -3
- google/cloud/sql/connector/sqldata_client.py +654 -0
- google/cloud/sql/connector/version.py +1 -1
- cloud_sql_python_connector-1.22.0.dist-info/RECORD +0 -26
- {cloud_sql_python_connector-1.22.0.dist-info → cloud_sql_python_connector-1.23.0.dist-info}/WHEEL +0 -0
- {cloud_sql_python_connector-1.22.0.dist-info → cloud_sql_python_connector-1.23.0.dist-info}/licenses/LICENSE +0 -0
- {cloud_sql_python_connector-1.22.0.dist-info → cloud_sql_python_connector-1.23.0.dist-info}/top_level.txt +0 -0
{cloud_sql_python_connector-1.22.0.dist-info → cloud_sql_python_connector-1.23.0.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cloud-sql-python-connector
|
|
3
|
-
Version: 1.
|
|
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.
|
|
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:
|
|
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 "
|
|
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 `"
|
|
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
|
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
cloud_sql_python_connector-1.23.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
|
|
2
|
+
google/cloud/sql/connector/__init__.py,sha256=pfa-FD-VRpYI49OUul9p6UFDp7G_yT2f6WS9rZMn8CM,1148
|
|
3
|
+
google/cloud/sql/connector/asyncpg.py,sha256=MpZhwFke0WXvYD3OcEF1Ok0qHl-CU7ZIPy85PCog5QY,2002
|
|
4
|
+
google/cloud/sql/connector/client.py,sha256=GfiZKDDBOxeA0yfqETQuaw3Nhg0BS71oQNZNxq3CooY,14991
|
|
5
|
+
google/cloud/sql/connector/connection_info.py,sha256=lwhrOG01efvvvR2gXiesiZ1BrXJ4iP7geoRi0zI80do,5666
|
|
6
|
+
google/cloud/sql/connector/connection_name.py,sha256=SCCVeWb8YN0f9My09_l9FGTr6iRbi1b_52TJQaS6xzM,2574
|
|
7
|
+
google/cloud/sql/connector/connector.py,sha256=at6WZJJCwQ3Ds8Ssd3ZF9bSJJYwN10Yxh-oK9UhkmFc,37843
|
|
8
|
+
google/cloud/sql/connector/enums.py,sha256=F_mUdwscpW2fAzw4XElSy4BWkWcGQAkBOAUG8bvd3vg,3118
|
|
9
|
+
google/cloud/sql/connector/exceptions.py,sha256=-QgsUq4gZaMrl3MH5KnsfJybEegAKW84-sdRmPKT-Dg,3137
|
|
10
|
+
google/cloud/sql/connector/instance.py,sha256=Lz4kjwBdp3IVb6xpjPEJkawR7LS89XPLZSOt-IDxunI,8677
|
|
11
|
+
google/cloud/sql/connector/lazy.py,sha256=MDJTAcB5iOqYYMewbzuX0RWh5PdIrY4RWpYfmFUYkr0,4918
|
|
12
|
+
google/cloud/sql/connector/monitored_cache.py,sha256=5YAVjdiQaywZOqzQlvx9HkPLxA8tlV0HhQDJFsa1_qc,6674
|
|
13
|
+
google/cloud/sql/connector/pg8000.py,sha256=tbqFSIoSguMX1hTZ4kWeBOKLhLHKX1Vq5SespfA0Y0w,1801
|
|
14
|
+
google/cloud/sql/connector/psycopg.py,sha256=UD7OFVJ7C_PPsiIWzpbi1k3YIkqC4rM1pQS08wPeSM0,10950
|
|
15
|
+
google/cloud/sql/connector/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
+
google/cloud/sql/connector/pymysql.py,sha256=MOau37nTOTesUR5Hor7lLtEckvvGThzjECEWQYHcM8U,2166
|
|
17
|
+
google/cloud/sql/connector/pytds.py,sha256=e-KBCqv0m3a7cRi9YmFHNuYqClhlJbf-KoF611w-1Ck,2304
|
|
18
|
+
google/cloud/sql/connector/rate_limiter.py,sha256=60k-r9h-nUBqovVIHnIGbW0NMgUGD4exH_rZ02ukNa0,2924
|
|
19
|
+
google/cloud/sql/connector/refresh_utils.py,sha256=Eghd-_uR5ndCGLsPgnyeUOoAvN7Tz4yzTlQFW4QWOjo,5228
|
|
20
|
+
google/cloud/sql/connector/resolver.py,sha256=4U8G0Pxwmy64qoRmP5shLnmIykxcGcGCoFSH_7tr120,6353
|
|
21
|
+
google/cloud/sql/connector/sqldata_client.py,sha256=gIgfgyYN5tBjYJxEWzvJkL67FCjhYxjg2Qs_2Z7QBhU,23862
|
|
22
|
+
google/cloud/sql/connector/utils.py,sha256=ApLG4z4H0S4lWXQ9PyclXbrEoY5VrshqN9QB6BG8lyg,4132
|
|
23
|
+
google/cloud/sql/connector/version.py,sha256=cbp_THzh62LsaoqJEz9Prs5EyZAWmeu6HB74bMAMqGY,598
|
|
24
|
+
cloud_sql_python_connector-1.23.0.dist-info/METADATA,sha256=7dGxD8x9D5bsEnn9BmzbZtSN1mMGpAmcqj8w6EFPRjo,31777
|
|
25
|
+
cloud_sql_python_connector-1.23.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
26
|
+
cloud_sql_python_connector-1.23.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
|
|
27
|
+
cloud_sql_python_connector-1.23.0.dist-info/RECORD,,
|
|
@@ -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":
|
|
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
|
-
|
|
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.
|
|
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
|