cloud-sql-python-connector 1.3.0__py2.py3-none-any.whl → 1.4.1__py2.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.1
2
2
  Name: cloud-sql-python-connector
3
- Version: 1.3.0
3
+ Version: 1.4.1
4
4
  Summary: The Cloud SQL Python Connector is a library that can be used alongside a database driver to allow users with sufficient permissions to connect to a Cloud SQL database without having to manually allowlist IPs or manage SSL certificates.
5
5
  Home-page: https://github.com/GoogleCloudPlatform/cloud-sql-python-connector
6
6
  Author: Google LLC
@@ -25,11 +25,11 @@ Requires-Dist: google-auth
25
25
  Provides-Extra: asyncpg
26
26
  Requires-Dist: asyncpg (==0.28.0) ; extra == 'asyncpg'
27
27
  Provides-Extra: pg8000
28
- Requires-Dist: pg8000 (==1.29.8) ; extra == 'pg8000'
28
+ Requires-Dist: pg8000 (==1.30.1) ; extra == 'pg8000'
29
29
  Provides-Extra: pymysql
30
30
  Requires-Dist: PyMySQL (==1.1.0) ; extra == 'pymysql'
31
31
  Provides-Extra: pytds
32
- Requires-Dist: python-tds (==1.12.0) ; extra == 'pytds'
32
+ Requires-Dist: python-tds (==1.13.0) ; extra == 'pytds'
33
33
 
34
34
  <p align="center">
35
35
  <a href="https://cloud.google.com/blog/topics/developers-practitioners/how-connect-cloud-sql-using-python-easy-way">
@@ -1,20 +1,21 @@
1
- cloud_sql_python_connector-1.3.0-py3.9-nspkg.pth,sha256=b0D5dZk3RUzK54tZ9iZDvLm7u8ltc5EzYrGCmhsuoNw,1698
1
+ cloud_sql_python_connector-1.4.1-py3.9-nspkg.pth,sha256=b0D5dZk3RUzK54tZ9iZDvLm7u8ltc5EzYrGCmhsuoNw,1698
2
2
  google/cloud/sql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  google/cloud/sql/connector/__init__.py,sha256=0PbPT7guIVFjTKy1mIkMge_BdiZDWooWf-Vll08nuIQ,876
4
4
  google/cloud/sql/connector/asyncpg.py,sha256=c4lAlvEgGf_eBq0G8MVNPRAJQQvo6DcwybiXDW36qkU,1838
5
- google/cloud/sql/connector/connector.py,sha256=I0WjRryj_RfRX2LNouiRiOigBCHPdQaMLZAHZppWJQw,14195
5
+ google/cloud/sql/connector/connector.py,sha256=TciqbF7R92eJKXHqhWZvPBRsff7oYF-3yeHCttfTO3w,14201
6
6
  google/cloud/sql/connector/exceptions.py,sha256=99sY_6UVuSeSg1jFusXOpPWEsbzDwk-LLo4WZkcsL2A,1649
7
- google/cloud/sql/connector/instance.py,sha256=NoizVdawvKpy89Gacp5oGUQUc92rk4-x7bJf6HEpuvI,17711
8
- google/cloud/sql/connector/pg8000.py,sha256=HfY5kHfk_2hb6dMc4Vr5fdyMiQDhwY_uxjbpuyXjYsM,2031
7
+ google/cloud/sql/connector/instance.py,sha256=fgbxXQ6qtJlofhgotxhu4T87ptJls99i_hT2NtsnuGs,17649
8
+ google/cloud/sql/connector/pg8000.py,sha256=EZuO7XgCkG_Y79NQlh3Vv8Ff2w85BFJyFVO237hx1GM,1814
9
+ google/cloud/sql/connector/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
9
10
  google/cloud/sql/connector/pymysql.py,sha256=wldUgwDPlPa8Nj5F3JaipuP8hJyvzlgOAJbRnOoaB1U,2105
10
11
  google/cloud/sql/connector/pytds.py,sha256=vKJoE7E2P0GrhZojg8bGZkqCMLc8dgKAcXE4ee7vEVc,2452
11
12
  google/cloud/sql/connector/rate_limiter.py,sha256=Ci3f-94090bj0cWJUu-vGZFc32IWRCyi8TIgChsQvxY,2954
12
13
  google/cloud/sql/connector/refresh_utils.py,sha256=m0kPpRDEQgrq5PBLhdeGNSiOWWY8oBA6d0pOoTznKII,9565
13
14
  google/cloud/sql/connector/utils.py,sha256=Y5I0kIAiT-Fb1xa50EKIJmyPBccd3lWCZ2OT4SbdxQI,4371
14
- google/cloud/sql/connector/version.py,sha256=SUVjzYavIesJC6lrq-I9zzQLpoo0hWsl0qAne7yszzQ,597
15
- cloud_sql_python_connector-1.3.0.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
16
- cloud_sql_python_connector-1.3.0.dist-info/METADATA,sha256=S7IpBlnZgwErnkE-BiZjRdxF36OiSh0f8-mZUtiDhaY,24144
17
- cloud_sql_python_connector-1.3.0.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
18
- cloud_sql_python_connector-1.3.0.dist-info/namespace_packages.txt,sha256=v8IaYqRE2a0onAGJIpZeFkkH83wXSWZRR9eOyfMwoTc,20
19
- cloud_sql_python_connector-1.3.0.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
20
- cloud_sql_python_connector-1.3.0.dist-info/RECORD,,
15
+ google/cloud/sql/connector/version.py,sha256=eEdgQtHsN2o2YsShYyjrQLZSoyk4nSu7NHvrSWUhnPc,597
16
+ cloud_sql_python_connector-1.4.1.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
17
+ cloud_sql_python_connector-1.4.1.dist-info/METADATA,sha256=jDNJl8YGthz1pqtRli4HpfJwrTp8x4LeIPfg1wuhlG4,24144
18
+ cloud_sql_python_connector-1.4.1.dist-info/WHEEL,sha256=bb2Ot9scclHKMOLDEHY6B2sicWOgugjFKaJsT7vwMQo,110
19
+ cloud_sql_python_connector-1.4.1.dist-info/namespace_packages.txt,sha256=v8IaYqRE2a0onAGJIpZeFkkH83wXSWZRR9eOyfMwoTc,20
20
+ cloud_sql_python_connector-1.4.1.dist-info/top_level.txt,sha256=_1QvSJIhFAGfxb79D6DhB7SUw2X6T4rwnz_LLrbcD3c,7
21
+ cloud_sql_python_connector-1.4.1.dist-info/RECORD,,
@@ -280,7 +280,7 @@ class Connector:
280
280
 
281
281
  except Exception:
282
282
  # with any exception, we attempt a force refresh, then throw the error
283
- instance.force_refresh()
283
+ await instance.force_refresh()
284
284
  raise
285
285
 
286
286
  def __enter__(self) -> Any:
@@ -104,10 +104,6 @@ class InstanceMetadata:
104
104
  "Upgrade your OpenSSL version to 1.1.1 for TLSv1.3 support."
105
105
  )
106
106
  self.context.minimum_version = ssl.TLSVersion.TLSv1_2
107
-
108
- # add request_ssl attribute to ssl.SSLContext, required for pg8000 driver
109
- self.context.request_ssl = False # type: ignore
110
-
111
107
  self.expiration = expiration
112
108
 
113
109
  # tmpdir and its contents are automatically deleted after the CA cert
@@ -259,7 +255,7 @@ class Instance:
259
255
  self._current = self._schedule_refresh(0)
260
256
  self._next = self._current
261
257
 
262
- def force_refresh(self) -> None:
258
+ async def force_refresh(self) -> None:
263
259
  """
264
260
  Forces a new refresh attempt immediately to be used for future connection attempts.
265
261
  """
@@ -267,8 +263,9 @@ class Instance:
267
263
  if not self._refresh_in_progress.is_set():
268
264
  self._next.cancel()
269
265
  self._next = self._schedule_refresh(0)
270
- # block all sequential connection attempts on the next refresh result
271
- self._current = self._next
266
+ # block all sequential connection attempts on the next refresh result if current is invalid
267
+ if not await _is_valid(self._current):
268
+ self._current = self._next
272
269
 
273
270
  async def _perform_refresh(self) -> InstanceMetadata:
274
271
  """Retrieves instance metadata and ephemeral certificate from the
@@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
13
  See the License for the specific language governing permissions and
14
14
  limitations under the License.
15
15
  """
16
+ import socket
16
17
  import ssl
17
18
  from typing import Any, TYPE_CHECKING
18
19
 
@@ -39,26 +40,26 @@ def connect(
39
40
  :rtype: pg8000.dbapi.Connection
40
41
  :returns: A pg8000 Connection object for the Cloud SQL instance.
41
42
  """
42
- # Connecting through pg8000 is done by passing in an SSL Context and setting the
43
- # "request_ssl" attr to false. This works because when "request_ssl" is false,
44
- # the driver skips the database level SSL/TLS exchange, but still uses the
45
- # ssl_context (if it is not None) to create the connection.
46
43
  try:
47
44
  import pg8000
48
45
  except ImportError:
49
46
  raise ImportError(
50
47
  'Unable to import module "pg8000." Please install and try again.'
51
48
  )
49
+
50
+ # Create socket and wrap with context.
51
+ sock = ctx.wrap_socket(
52
+ socket.create_connection((ip_address, SERVER_PROXY_PORT)),
53
+ server_hostname=ip_address,
54
+ )
55
+
52
56
  user = kwargs.pop("user")
53
57
  db = kwargs.pop("db")
54
58
  passwd = kwargs.pop("password", None)
55
- setattr(ctx, "request_ssl", False)
56
59
  return pg8000.dbapi.connect(
57
60
  user,
58
61
  database=db,
59
62
  password=passwd,
60
- host=ip_address,
61
- port=SERVER_PROXY_PORT,
62
- ssl_context=ctx,
63
+ sock=sock,
63
64
  **kwargs,
64
65
  )
File without changes
@@ -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.3.0"
15
+ __version__ = "1.4.1"