之前使用 boto3 连接到 AWS Glue 并返回表信息的 python 脚本 (3.12) 存在问题。
错误信息是:
“botocore.exceptions.SSLError:SSL 验证失败 https://glue.us-west-2.amazonaws.com/ [SSL:CERTIFICATE_VERIFY_FAILED] 证书验证失败:无法获取本地颁发者证书 (_ssl.c: 1000)”
我使用单独的脚本首先通过 AWS 进行身份验证,然后运行如下代码:
import boto3
import json
import datetime
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
next_token = ""
client = boto3.client('glue', region_name ='us-west-2')
crawler_tables = []
while True:
response = client.get_tables(DatabaseName = 'XXXX', NextToken = next_token)
#print(response)
def myconverter(o):
if isinstance(o,datetime.datetime):
return o.__str__()
print(json.dumps(response, default=myconverter))
for tables in response['TableList']:
for columns in tables['StorageDescriptor']['Columns']:
crawler_tables.append(tables['Name'] + '|' + columns['Name']+ '|' + columns['Type'])
next_token = response.get('NextToken')
if next_token is None:
break
print(crawler_tables)
该错误是新错误,因为脚本在 8-12 个月前运行,并且相信某些安全/网络或工作站权限已更改,但无法找到根本原因。
我尝试使用 github Gist install Cerfificates.command 安装证书,但出现错误: OSError:[WinError 1314]客户端不拥有所需的权限:'..\.venv\Lib\site-package