【发布时间】:2019-10-29 05:09:33
【问题描述】:
我正在尝试使用 boto3 python 脚本创建连接。它是与 ec2 实例上的 mysql 数据库的连接。我正在使用下面的脚本。我收到以下错误消息。我不确定我错过了什么。我已经使用类似的脚本毫无问题地创建了胶水爬虫。除了我在 ConnectionProperties 中添加了用户名和密码外,我几乎都遵循 boto3 文档。我不确定这是否正确。如果我做对了,或者我需要在我的代码中修复什么,有人可以告诉我吗?
代码:
# create new connection
response = client.create_connection(
ConnectionInput={
'Name': 'tst_scrpt',
'ConnectionType': 'JDBC',
'ConnectionProperties': {
'string': 'jdbc:mysql://dataxxx:3306/disxxx',
'username':'root',
'password':'ip1k5PNCxxxxx'
}
,
'PhysicalConnectionRequirements': {
'SubnetId': 'subnet-0436167b7cbxxxx',
'SecurityGroupIdList': [
'sg-02c3f45ce51exxxxx'
]
}
}
)
错误:
---------------------------------------------------------------------------
InvalidInputException Traceback (most recent call last)
<ipython-input-18-6ac0bdcfa816> in <module>
16 'SubnetId': 'subnet-0436167b7cbxxxx',
17 'SecurityGroupIdList': [
---> 18 'sg-02c3f45ce51exxxxx'
19 ]
20 # ,
/anaconda3/envs/py36/lib/python3.6/site-packages/botocore/client.py in _api_call(self, *args, **kwargs)
355 "%s() only accepts keyword arguments." % py_operation_name)
356 # The "self" in this scope is referring to the BaseClient.
--> 357 return self._make_api_call(operation_name, kwargs)
358
359 _api_call.__name__ = str(py_operation_name)
/anaconda3/envs/py36/lib/python3.6/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params)
659 error_code = parsed_response.get("Error", {}).get("Code")
660 error_class = self.exceptions.from_code(error_code)
--> 661 raise error_class(parsed_response, operation_name)
662 else:
663 return parsed_response
InvalidInputException: An error occurred (InvalidInputException) when calling the CreateConnection operation: Validation for connection properties failed
【问题讨论】:
-
'string'连接属性是什么?我想应该是host或其他东西,但不是string。 -
@Lamanus 谢谢,应该是 JDBC_CONNECTION_URL
标签: python-3.x amazon-web-services amazon-ec2 boto3