简体   繁体   English

如何将 AWS Glue 作业连接到 Salesforce

[英]How to connect AWS Glue Job to Salesforce

I am following questions like this and blogs like t his one but I cannot make the connection work due to (I think) library versions conflict.我正在关注这样的问题和类似他的博客,但由于(我认为)库版本冲突,我无法使连接正常工作。

I want to use this library , which afaik is the most used and referenced one, to connect from a aws glue job to Salesforce.我想使用这个库(afaik 是最常用和引用最多的库)从 aws 胶水作业连接到 Salesforce。 This code works on my local machine, but on glue I get the following message when I use "python shell" configuration: ERROR: botocore 1.12.232 has requirement urllib3<1.26,>=1.20; python_version >= "3.4", but you'll have urllib3 1.26.2 which is incompatible.这段代码在我的本地机器上工作,但是当我使用“python shell”配置时,我收到以下消息: ERROR: botocore 1.12.232 has requirement urllib3<1.26,>=1.20; python_version >= "3.4", but you'll have urllib3 1.26.2 which is incompatible. ERROR: botocore 1.12.232 has requirement urllib3<1.26,>=1.20; python_version >= "3.4", but you'll have urllib3 1.26.2 which is incompatible.

Or, if I use "spark" option: Traceback (most recent call last): File "/tmp/bp-etl-crm-sparkV2", line 1, in <module> from simple_salesforce import Salesforce File "/tmp/simple_salesforce-1.10.1-py2.py3-none-any.whl/simple_salesforce/__init__.py", line 4, in <module> from.api import Salesforce, SFType File "/tmp/simple_salesforce-1.10.1-py2.py3-none-any.whl/simple_salesforce/api.py", line 18, in <module> from.login import SalesforceLogin File "/tmp/simple_salesforce-1.10.1-py2.py3-none-any.whl/simple_salesforce/login.py", line 16, in <module> from authlib.jose import jwt ModuleNotFoundError: No module named 'authlib'或者,如果我使用“spark”选项: Traceback (most recent call last): File "/tmp/bp-etl-crm-sparkV2", line 1, in <module> from simple_salesforce import Salesforce File "/tmp/simple_salesforce-1.10.1-py2.py3-none-any.whl/simple_salesforce/__init__.py", line 4, in <module> from.api import Salesforce, SFType File "/tmp/simple_salesforce-1.10.1-py2.py3-none-any.whl/simple_salesforce/api.py", line 18, in <module> from.login import SalesforceLogin File "/tmp/simple_salesforce-1.10.1-py2.py3-none-any.whl/simple_salesforce/login.py", line 16, in <module> from authlib.jose import jwt ModuleNotFoundError: No module named 'authlib'

The code is as simple as a connection and a query, which again, I've tested and the credentials and connection do work when I try from a local console and not aws glue:代码就像连接和查询一样简单,我再次测试过,当我从本地控制台尝试而不是 aws 胶水时,凭据和连接确实有效:

from simple_salesforce import Salesforce

def main():
    print("INIT")
    sf = Salesforce(username='username', password='pw', security_token='securitytoken', domain='test')
    res_bulk = sf.bulk.Account.query('SELECT Id, Name FROM Table')
    print(res_bulk)

if __name__ == "__main__":
    main()

What have I tried so far:到目前为止我尝试了什么:

  • As I said, I have tried to both configure the job as python shell, with Glue 1.0, and Spark with Glue 2.0.正如我所说,我尝试将作业配置为 python shell,使用 Glue 1.0 和使用 Glue 2.0 的 Spark。 Both fail due to dependencies problems.由于依赖问题,两者都失败了。

  • I have tried downgrading the simple-salesforce version.我曾尝试降级 simple-salesforce 版本。 So far none have worked, it keeps throwing ERROR: botocore 1.12.232 has requirement urllib3<1.26,>=1.20; python_version >= "3.4", but you'll have urllib3 1.26.2 which is incompatible.到目前为止,没有任何工作,它一直在抛出ERROR: botocore 1.12.232 has requirement urllib3<1.26,>=1.20; python_version >= "3.4", but you'll have urllib3 1.26.2 which is incompatible. ERROR: botocore 1.12.232 has requirement urllib3<1.26,>=1.20; python_version >= "3.4", but you'll have urllib3 1.26.2 which is incompatible.

  • I have tried getting urllib version lower than 1.26.2, uploading it to S3, and adding it to the list of libraries to be used by my code.我尝试获取低于 1.26.2 的 urllib 版本,将其上传到 S3,并将其添加到我的代码要使用的库列表中。 This has not worked so far, but I am not sure why, since I do not know what does Glue do when ordered to use a certain version of a library it is designed to use regardless of what you do, like urllib.到目前为止,这还没有奏效,但我不知道为什么,因为我不知道 Glue 在被命令使用某个版本的库时会做什么,无论你做什么,它都被设计为使用,比如 urllib。

Any ideas as to what could I be doing wrong, or what else could I try to make it work.关于我可能做错什么的任何想法,或者我还能尝试使其发挥作用。

simple_salesforce module has dependencies on authlib, cryptography etc. On Glue version 2.0 (Spark 2.4, python 3), you will need to add below parameters to the glue job: simple_salesforce 模块依赖于 authlib、密码学等。在 Glue 版本 2.0(Spark 2.4、python 3)上,您需要将以下参数添加到胶水作业中:

--additional-python-modules: cryptography==3.0,simple-salesforce==1.11.1 image_screenshot --additional-python-modules: 密码学==3.0,simple-salesforce==1.11.1 image_screenshot

You have to edit the job and under "Security configuration, script libraries, and job parameters (optional)" you can find the "Job Parameters" option.您必须编辑作业并在“安全配置、脚本库和作业参数(可选)”下找到“作业参数”选项。

(these versions are compatible and have worked for me) (这些版本是兼容的并且对我有用)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM