繁体   English   中英

带有Oracle的AWS Python Lambda

[英]AWS Python Lambda with Oracle

我正在尝试使用python从AWS Lambda连接到Oracle数据库 我设法打包了cx_Oracle,但是环境找不到依赖项。

我已经压缩了内容,其中包含cx_Oracle.socx_Oracle-5.2.1-py2.7.egg-info (在64位AWX Linux上创建)。 我还将来自instantclient-basic-linux.x64-12.1.0.2.0.zip的文件添加到该zip文件的local / lib中。

我得到的错误是

import cx_Oracle

ImportError: libaio.so.1: cannot open shared object file: No such file or directory

我像这样动态地更改python中的环境变量:

oracledir = os.path.join(os.getcwd(), 'local', 'lib')
libdir = os.environ['LD_LIBRARY_PATH'] + ":" + os.path.join(os.getcwd(), 'local', 'lib')

command = 'LD_LIBRARY_PATH={} ORACLE_HOME={} python OracleWorker.py "{}"'.format(libdir, oracledir, args)
subprocess.call(command, shell=True)

OracleWorker.py从import cx_Oracle开始

解决。 通过运行ldd cx_Oracle.so| grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' /destination添加了所有依赖性ldd cx_Oracle.so| grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' /destination ldd cx_Oracle.so| grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' /destination ldd cx_Oracle.so| grep "=> /" | awk '{print $3}' | xargs -I '{}' cp -v '{}' /destination所有这些文件添加到lambda zip中的lib文件夹中

暂无
暂无

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

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