AWS Python Lambda with Oracle - OID Generation Failed
<p>I'm trying to connect to an Oracle DB using AWS Lambda Python code.</p>

<p>My code is below:</p>

<pre><code>import sys, os
import cx_Oracle
import traceback

def main_handler(event, context):

  # Enter your database connection details here
  host = "server_ip_or_name"
  port = 1521
  sid = "server_sid"
  username = "myusername"
  password = "mypassword"

  try:
    dsn = cx_Oracle.makedsn(host, port, sid)
    print dsn
    connection = cx_Oracle.Connection("%s/%s@%s" % (username, password, dsn))
    cursor = connection.cursor()
    cursor.execute("select 1 / 0 from dual")
  except cx_Oracle.DatabaseError, exc:
    error, = exc.args
    print &gt;&gt; sys.stderr, "Oracle-Error-Code:", error.code
    print &gt;&gt; sys.stderr, "Oracle-Error-Message:", error.message
    tb = traceback.format_exc()
  else:
    tb = "No error"
  finally:
    print tb


if __name__ == "__main__":
  main_handler(sys.argv[0], None)
</code></pre>

<p>If have already added all dependencies in "lib" folder, thanks to <a href="http://stackoverflow.com/questions/37734748/aws-python-lambda-with-oracle/37753311#37753311">AWS Python Lambda with Oracle</a></p>

<p>When running this code, I'm getting:
    DatabaseError: ORA-21561: OID generation failed</p>

<p>i've tried to connect using IP of the Oracle server and the name: same error.</p>

<p>Here is the output of the error</p>

<pre><code>Oracle-Error-Code: 21561
Oracle-Error-Message: ORA-21561: OID generation failed

Traceback (most recent call last):
  File "/var/task/main.py", line 20, in main_handler
  connection = cx_Oracle.Connection("%s/%s@%s" % (username, password, dsn))
DatabaseError: ORA-21561: OID generation failed
</code></pre>

<p>For those who have successfully run the CX_Oracle in AWS Lambda Python, can you please help ?</p>

<p>Thanks</p>

<p>See the following other question for the resolution to this problem.</p>

<p><a href="http://stackoverflow.com/questions/31338916/sqlplus-remote-connection-giving-ora-21561">sqlplus remote connection giving ORA-21561</a></p>

<p>Effectively the client requires a host name in order to generate a unique identifier which is used when connecting to the database.</p>

python amazon-web-services aws-lambda cx-oracle