cloud-sql-python-connector 1.21.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.
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/PKG-INFO +31 -11
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/README.md +25 -4
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/cloud_sql_python_connector.egg-info/PKG-INFO +31 -11
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/cloud_sql_python_connector.egg-info/SOURCES.txt +2 -0
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/cloud_sql_python_connector.egg-info/requires.txt +4 -3
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/asyncpg.py +3 -1
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/client.py +15 -3
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/connection_info.py +8 -1
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/connector.py +351 -134
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/enums.py +4 -0
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/exceptions.py +39 -0
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/instance.py +2 -2
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/lazy.py +2 -2
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/monitored_cache.py +45 -15
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/pg8000.py +3 -1
- cloud_sql_python_connector-1.23.0/google/cloud/sql/connector/psycopg.py +323 -0
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/pymysql.py +7 -0
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/pytds.py +1 -1
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/refresh_utils.py +4 -3
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/resolver.py +18 -5
- cloud_sql_python_connector-1.23.0/google/cloud/sql/connector/sqldata_client.py +654 -0
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/version.py +1 -1
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/pyproject.toml +20 -7
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/LICENSE +0 -0
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/cloud_sql_python_connector.egg-info/dependency_links.txt +0 -0
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/cloud_sql_python_connector.egg-info/top_level.txt +0 -0
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/__init__.py +0 -0
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/connection_name.py +0 -0
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/py.typed +0 -0
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/rate_limiter.py +0 -0
- {cloud_sql_python_connector-1.21.0 → cloud_sql_python_connector-1.23.0}/google/cloud/sql/connector/utils.py +0 -0
- {cloud_sql_python_connector-1.21.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.
|
|
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
|
|
@@ -37,6 +34,8 @@ Provides-Extra: pytds
|
|
|
37
34
|
Requires-Dist: python-tds>=1.15.0; extra == "pytds"
|
|
38
35
|
Provides-Extra: asyncpg
|
|
39
36
|
Requires-Dist: asyncpg>=0.30.0; extra == "asyncpg"
|
|
37
|
+
Provides-Extra: psycopg
|
|
38
|
+
Requires-Dist: psycopg>=3.1.0; extra == "psycopg"
|
|
40
39
|
Dynamic: license-file
|
|
41
40
|
|
|
42
41
|
<p align="center">
|
|
@@ -82,7 +81,8 @@ providing the following benefits:
|
|
|
82
81
|
The Cloud SQL Python Connector is a package to be used alongside a database driver.
|
|
83
82
|
Currently supported drivers are:
|
|
84
83
|
- [`pymysql`](https://github.com/PyMySQL/PyMySQL) (MySQL)
|
|
85
|
-
- [`pg8000`](https://
|
|
84
|
+
- [`pg8000`](https://codeberg.org/tlocke/pg8000) (PostgreSQL)
|
|
85
|
+
- [`psycopg`](https://github.com/psycopg/psycopg) (PostgreSQL)
|
|
86
86
|
- [`asyncpg`](https://github.com/MagicStack/asyncpg) (PostgreSQL)
|
|
87
87
|
- [`pytds`](https://github.com/denisenkom/pytds) (SQL Server)
|
|
88
88
|
|
|
@@ -97,12 +97,16 @@ based on your database dialect.
|
|
|
97
97
|
pip install "cloud-sql-python-connector[pymysql]"
|
|
98
98
|
```
|
|
99
99
|
### Postgres
|
|
100
|
-
There are
|
|
100
|
+
There are three different database drivers that are supported for the Postgres dialect:
|
|
101
101
|
|
|
102
102
|
#### pg8000
|
|
103
103
|
```
|
|
104
104
|
pip install "cloud-sql-python-connector[pg8000]"
|
|
105
105
|
```
|
|
106
|
+
#### psycopg
|
|
107
|
+
```
|
|
108
|
+
pip install "cloud-sql-python-connector[psycopg]"
|
|
109
|
+
```
|
|
106
110
|
#### asyncpg
|
|
107
111
|
```
|
|
108
112
|
pip install "cloud-sql-python-connector[asyncpg]"
|
|
@@ -178,6 +182,18 @@ pool = sqlalchemy.create_engine(
|
|
|
178
182
|
db="my-db-name"
|
|
179
183
|
),
|
|
180
184
|
)
|
|
185
|
+
|
|
186
|
+
# Or with Postgres (psycopg):
|
|
187
|
+
pool = sqlalchemy.create_engine(
|
|
188
|
+
"postgresql+psycopg://",
|
|
189
|
+
creator=lambda: connector.connect(
|
|
190
|
+
"project:region:instance",
|
|
191
|
+
"psycopg",
|
|
192
|
+
user="my-user",
|
|
193
|
+
password="my-password",
|
|
194
|
+
db="my-db-name"
|
|
195
|
+
),
|
|
196
|
+
)
|
|
181
197
|
```
|
|
182
198
|
|
|
183
199
|
The returned connection pool engine can then be used to query and modify the database.
|
|
@@ -225,7 +241,7 @@ from google.cloud.sql.connector import Connector
|
|
|
225
241
|
|
|
226
242
|
# Note: all parameters below are optional
|
|
227
243
|
connector = Connector(
|
|
228
|
-
ip_type="public", # can also be "private" or "
|
|
244
|
+
ip_type="public", # can also be "private", "psc", or "sql_data"
|
|
229
245
|
enable_iam_auth=False,
|
|
230
246
|
timeout=30,
|
|
231
247
|
credentials=custom_creds, # google.auth.credentials.Credentials
|
|
@@ -303,7 +319,11 @@ with, set the `ip_type` keyword argument when initializing a `Connector()` or wh
|
|
|
303
319
|
calling `connector.connect()`.
|
|
304
320
|
|
|
305
321
|
Possible values for `ip_type` are `"public"` (default value),
|
|
306
|
-
`"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`).
|
|
307
327
|
|
|
308
328
|
Example:
|
|
309
329
|
|
|
@@ -41,7 +41,8 @@ providing the following benefits:
|
|
|
41
41
|
The Cloud SQL Python Connector is a package to be used alongside a database driver.
|
|
42
42
|
Currently supported drivers are:
|
|
43
43
|
- [`pymysql`](https://github.com/PyMySQL/PyMySQL) (MySQL)
|
|
44
|
-
- [`pg8000`](https://
|
|
44
|
+
- [`pg8000`](https://codeberg.org/tlocke/pg8000) (PostgreSQL)
|
|
45
|
+
- [`psycopg`](https://github.com/psycopg/psycopg) (PostgreSQL)
|
|
45
46
|
- [`asyncpg`](https://github.com/MagicStack/asyncpg) (PostgreSQL)
|
|
46
47
|
- [`pytds`](https://github.com/denisenkom/pytds) (SQL Server)
|
|
47
48
|
|
|
@@ -56,12 +57,16 @@ based on your database dialect.
|
|
|
56
57
|
pip install "cloud-sql-python-connector[pymysql]"
|
|
57
58
|
```
|
|
58
59
|
### Postgres
|
|
59
|
-
There are
|
|
60
|
+
There are three different database drivers that are supported for the Postgres dialect:
|
|
60
61
|
|
|
61
62
|
#### pg8000
|
|
62
63
|
```
|
|
63
64
|
pip install "cloud-sql-python-connector[pg8000]"
|
|
64
65
|
```
|
|
66
|
+
#### psycopg
|
|
67
|
+
```
|
|
68
|
+
pip install "cloud-sql-python-connector[psycopg]"
|
|
69
|
+
```
|
|
65
70
|
#### asyncpg
|
|
66
71
|
```
|
|
67
72
|
pip install "cloud-sql-python-connector[asyncpg]"
|
|
@@ -137,6 +142,18 @@ pool = sqlalchemy.create_engine(
|
|
|
137
142
|
db="my-db-name"
|
|
138
143
|
),
|
|
139
144
|
)
|
|
145
|
+
|
|
146
|
+
# Or with Postgres (psycopg):
|
|
147
|
+
pool = sqlalchemy.create_engine(
|
|
148
|
+
"postgresql+psycopg://",
|
|
149
|
+
creator=lambda: connector.connect(
|
|
150
|
+
"project:region:instance",
|
|
151
|
+
"psycopg",
|
|
152
|
+
user="my-user",
|
|
153
|
+
password="my-password",
|
|
154
|
+
db="my-db-name"
|
|
155
|
+
),
|
|
156
|
+
)
|
|
140
157
|
```
|
|
141
158
|
|
|
142
159
|
The returned connection pool engine can then be used to query and modify the database.
|
|
@@ -184,7 +201,7 @@ from google.cloud.sql.connector import Connector
|
|
|
184
201
|
|
|
185
202
|
# Note: all parameters below are optional
|
|
186
203
|
connector = Connector(
|
|
187
|
-
ip_type="public", # can also be "private" or "
|
|
204
|
+
ip_type="public", # can also be "private", "psc", or "sql_data"
|
|
188
205
|
enable_iam_auth=False,
|
|
189
206
|
timeout=30,
|
|
190
207
|
credentials=custom_creds, # google.auth.credentials.Credentials
|
|
@@ -262,7 +279,11 @@ with, set the `ip_type` keyword argument when initializing a `Connector()` or wh
|
|
|
262
279
|
calling `connector.connect()`.
|
|
263
280
|
|
|
264
281
|
Possible values for `ip_type` are `"public"` (default value),
|
|
265
|
-
`"private"`, and `"
|
|
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`).
|
|
266
287
|
|
|
267
288
|
Example:
|
|
268
289
|
|
|
@@ -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
|
|
@@ -37,6 +34,8 @@ Provides-Extra: pytds
|
|
|
37
34
|
Requires-Dist: python-tds>=1.15.0; extra == "pytds"
|
|
38
35
|
Provides-Extra: asyncpg
|
|
39
36
|
Requires-Dist: asyncpg>=0.30.0; extra == "asyncpg"
|
|
37
|
+
Provides-Extra: psycopg
|
|
38
|
+
Requires-Dist: psycopg>=3.1.0; extra == "psycopg"
|
|
40
39
|
Dynamic: license-file
|
|
41
40
|
|
|
42
41
|
<p align="center">
|
|
@@ -82,7 +81,8 @@ providing the following benefits:
|
|
|
82
81
|
The Cloud SQL Python Connector is a package to be used alongside a database driver.
|
|
83
82
|
Currently supported drivers are:
|
|
84
83
|
- [`pymysql`](https://github.com/PyMySQL/PyMySQL) (MySQL)
|
|
85
|
-
- [`pg8000`](https://
|
|
84
|
+
- [`pg8000`](https://codeberg.org/tlocke/pg8000) (PostgreSQL)
|
|
85
|
+
- [`psycopg`](https://github.com/psycopg/psycopg) (PostgreSQL)
|
|
86
86
|
- [`asyncpg`](https://github.com/MagicStack/asyncpg) (PostgreSQL)
|
|
87
87
|
- [`pytds`](https://github.com/denisenkom/pytds) (SQL Server)
|
|
88
88
|
|
|
@@ -97,12 +97,16 @@ based on your database dialect.
|
|
|
97
97
|
pip install "cloud-sql-python-connector[pymysql]"
|
|
98
98
|
```
|
|
99
99
|
### Postgres
|
|
100
|
-
There are
|
|
100
|
+
There are three different database drivers that are supported for the Postgres dialect:
|
|
101
101
|
|
|
102
102
|
#### pg8000
|
|
103
103
|
```
|
|
104
104
|
pip install "cloud-sql-python-connector[pg8000]"
|
|
105
105
|
```
|
|
106
|
+
#### psycopg
|
|
107
|
+
```
|
|
108
|
+
pip install "cloud-sql-python-connector[psycopg]"
|
|
109
|
+
```
|
|
106
110
|
#### asyncpg
|
|
107
111
|
```
|
|
108
112
|
pip install "cloud-sql-python-connector[asyncpg]"
|
|
@@ -178,6 +182,18 @@ pool = sqlalchemy.create_engine(
|
|
|
178
182
|
db="my-db-name"
|
|
179
183
|
),
|
|
180
184
|
)
|
|
185
|
+
|
|
186
|
+
# Or with Postgres (psycopg):
|
|
187
|
+
pool = sqlalchemy.create_engine(
|
|
188
|
+
"postgresql+psycopg://",
|
|
189
|
+
creator=lambda: connector.connect(
|
|
190
|
+
"project:region:instance",
|
|
191
|
+
"psycopg",
|
|
192
|
+
user="my-user",
|
|
193
|
+
password="my-password",
|
|
194
|
+
db="my-db-name"
|
|
195
|
+
),
|
|
196
|
+
)
|
|
181
197
|
```
|
|
182
198
|
|
|
183
199
|
The returned connection pool engine can then be used to query and modify the database.
|
|
@@ -225,7 +241,7 @@ from google.cloud.sql.connector import Connector
|
|
|
225
241
|
|
|
226
242
|
# Note: all parameters below are optional
|
|
227
243
|
connector = Connector(
|
|
228
|
-
ip_type="public", # can also be "private" or "
|
|
244
|
+
ip_type="public", # can also be "private", "psc", or "sql_data"
|
|
229
245
|
enable_iam_auth=False,
|
|
230
246
|
timeout=30,
|
|
231
247
|
credentials=custom_creds, # google.auth.credentials.Credentials
|
|
@@ -303,7 +319,11 @@ with, set the `ip_type` keyword argument when initializing a `Connector()` or wh
|
|
|
303
319
|
calling `connector.connect()`.
|
|
304
320
|
|
|
305
321
|
Possible values for `ip_type` are `"public"` (default value),
|
|
306
|
-
`"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`).
|
|
307
327
|
|
|
308
328
|
Example:
|
|
309
329
|
|
|
@@ -18,11 +18,13 @@ google/cloud/sql/connector/instance.py
|
|
|
18
18
|
google/cloud/sql/connector/lazy.py
|
|
19
19
|
google/cloud/sql/connector/monitored_cache.py
|
|
20
20
|
google/cloud/sql/connector/pg8000.py
|
|
21
|
+
google/cloud/sql/connector/psycopg.py
|
|
21
22
|
google/cloud/sql/connector/py.typed
|
|
22
23
|
google/cloud/sql/connector/pymysql.py
|
|
23
24
|
google/cloud/sql/connector/pytds.py
|
|
24
25
|
google/cloud/sql/connector/rate_limiter.py
|
|
25
26
|
google/cloud/sql/connector/refresh_utils.py
|
|
26
27
|
google/cloud/sql/connector/resolver.py
|
|
28
|
+
google/cloud/sql/connector/sqldata_client.py
|
|
27
29
|
google/cloud/sql/connector/utils.py
|
|
28
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
|
-
|
|
7
|
-
protobuf
|
|
8
|
-
googleapis-common-protos
|
|
6
|
+
google-cloud-sql>=0.1.1
|
|
9
7
|
|
|
10
8
|
[asyncpg]
|
|
11
9
|
asyncpg>=0.30.0
|
|
@@ -13,6 +11,9 @@ asyncpg>=0.30.0
|
|
|
13
11
|
[pg8000]
|
|
14
12
|
pg8000>=1.31.1
|
|
15
13
|
|
|
14
|
+
[psycopg]
|
|
15
|
+
psycopg>=3.1.0
|
|
16
|
+
|
|
16
17
|
[pymysql]
|
|
17
18
|
PyMySQL>=1.1.0
|
|
18
19
|
|
|
@@ -51,7 +51,9 @@ async def connect(
|
|
|
51
51
|
'Unable to import module "asyncpg." Please install and try again.'
|
|
52
52
|
)
|
|
53
53
|
user = kwargs.pop("user")
|
|
54
|
-
db = kwargs.pop("db")
|
|
54
|
+
db = kwargs.pop("database", kwargs.pop("db", None))
|
|
55
|
+
if db is None:
|
|
56
|
+
raise KeyError("database")
|
|
55
57
|
passwd = kwargs.pop("password", None)
|
|
56
58
|
|
|
57
59
|
return await asyncpg.connect(
|
|
@@ -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
|