问题描述
有人知道如何将Google Cloud Function(Python)连接到Oracle数据库吗?我尝试在云函数中导入cx_Oracle库.但这显示了错误
Does anyone know, how to connect google cloud function(Python) to an Oracle database ? I tried importing cx_Oracle library in cloud function. But it shows an error
以下是main.py代码:
Following is main.py code:
import cx_Oracle
def import_data(request):
request_json = request.get_json()
if request_json and 'message' in request_json:
con = cx_Oracle.connect("username", "password", "host:port/SID")
print(con.version)
con.close
以下是required.txt
Following is requirement.txt
# Function dependencies, for example:
# package>=version
cx_Oracle==6.0b1
推荐答案
似乎Google Cloud Functions 不支持共享库(换句话说,它仅支持纯python"库),而cx_oracle依赖于此.遗憾的是,我无法找到纯Python的Oracle库,因此目前尚不支持.
It seems Google Cloud Functions does not support shared libraries (in other words, it only supports "pure python" libraries) and that cx_oracle depends on this. Sadly I haven't been able to find a pure-python Oracle library, so for now this is not supported.
您最好的选择是使用App Engine Flexible,因为它是允许使用非纯python库. cl_oracle应该可以使用它.
Your best bet is to use App Engine Flexible as it the closest equivalent service that allows non-pure python libraries. cl_oracle should work with it.
这篇关于将Google Cloud Function连接到Oracle数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!