I\'m trying to connect to an Oracle DB using AWS Lambda Python code.
My code is below:
import sys, os
import cx_Oracle
import traceback
def main_han
Ok, here is the explanation: Oracle has a funny behavior where if the hostname given by hostname can't be resolved, it will fail connecting to the DB. Fortunately, in Linux, one can override the DNS entry for a session by writing an alias file in /tmp, then setting the environment variable HOSTALIASES to that file.
So adding this code to my function help to generate this file, and now I can successfully connect:
f = open('/tmp/HOSTALIASES','w')
str_host = os.uname()[1]
f.write(str_host + ' localhost\n')
f.close()
Hope it can help someone else !