Accessing Oracle from AWS Lambda in PythonCannot use Requests-Module on AWS LambdaHow can I access Oracle from Python?How to create AWS Lambda deployment package that uses Couchbase Python clientIs AWS Lambda CloudWatch logging synchronous?How do you import modules from google.cloud for use in AWS Lambda?Access SOAP request in AWS LambdaCan't create s3 resource/client in boto3how to upload python code with libraries to aws lambda from windows local machine using aws consoleGoogle Cloud Platform API for Python and AWS Lambda Incompatibility: Cannot import name 'cygrpc'How to install Numpy and Pandas for AWS Lambdas?Cognito user pool implementation on Node Lambda serverCalling secured API from NodeJS Lambda

How many people need to be born every 8 years to sustain population?

How to make a list of partial sums using forEach

Do I have to know the General Relativity theory to understand the concept of inertial frame?

How to test the sharpness of a knife?

How to understand "he realized a split second too late was also a mistake"

I'm just a whisper. Who am I?

Can I say "fingers" when referring to toes?

Is there anyway, I can have two passwords for my wi-fi

Why didn’t Eve recognize the little cockroach as a living organism?

Why does a 97 / 92 key piano exist by Bösendorfer?

Echo with obfuscation

Typing CO_2 easily

Possible Eco thriller, man invents a device to remove rain from glass

Overlapping circles covering polygon

"Oh no!" in Latin

Animation: customize bounce interpolation

Are Captain Marvel's powers affected by Thanos breaking the Tesseract and claiming the stone?

How to write Quadratic equation with negative coefficient

Review your own paper in Mathematics

Unable to disable Microsoft Store in domain environment

If the only attacker is removed from combat, is a creature still counted as having attacked this turn?

Why is the principal energy of an electron lower for excited electrons in a higher energy state?

Can I cause damage to electrical appliances by unplugging them when they are turned on?

Determining multivariate least squares with constraint



Accessing Oracle from AWS Lambda in Python


Cannot use Requests-Module on AWS LambdaHow can I access Oracle from Python?How to create AWS Lambda deployment package that uses Couchbase Python clientIs AWS Lambda CloudWatch logging synchronous?How do you import modules from google.cloud for use in AWS Lambda?Access SOAP request in AWS LambdaCan't create s3 resource/client in boto3how to upload python code with libraries to aws lambda from windows local machine using aws consoleGoogle Cloud Platform API for Python and AWS Lambda Incompatibility: Cannot import name 'cygrpc'How to install Numpy and Pandas for AWS Lambdas?Cognito user pool implementation on Node Lambda serverCalling secured API from NodeJS Lambda













0















I am writing (hopefully) a simply AWS Lambda that will do an RDS Oracle SQL SELECT and email the results. So far I have been using the Lambda Management Console, but all the examples I've run across talk about making a Lambda Deployment Package. So my first question is can I do this from the Lambda Management Console?



Next question I have is what to import for the Oracle DB API? In all the examples I have seen, they download and build a package with pip, but that would then seem to imply using a Deployment Package (see above). Trying to import any of these modules listed in the examples simply give "No module named "...



After writing the above I dug into the boto3 API referrence and came up with:



import boto3
client = boto3.client('rds-data')


But it gives the error: Unknown service: 'rds-data'.



So I'm still lost.



As you can probably tell, I'm new to the Lambda environment. Any suggestions or examples would be greatly appreciated. Thanks.










share|improve this question




























    0















    I am writing (hopefully) a simply AWS Lambda that will do an RDS Oracle SQL SELECT and email the results. So far I have been using the Lambda Management Console, but all the examples I've run across talk about making a Lambda Deployment Package. So my first question is can I do this from the Lambda Management Console?



    Next question I have is what to import for the Oracle DB API? In all the examples I have seen, they download and build a package with pip, but that would then seem to imply using a Deployment Package (see above). Trying to import any of these modules listed in the examples simply give "No module named "...



    After writing the above I dug into the boto3 API referrence and came up with:



    import boto3
    client = boto3.client('rds-data')


    But it gives the error: Unknown service: 'rds-data'.



    So I'm still lost.



    As you can probably tell, I'm new to the Lambda environment. Any suggestions or examples would be greatly appreciated. Thanks.










    share|improve this question


























      0












      0








      0


      1






      I am writing (hopefully) a simply AWS Lambda that will do an RDS Oracle SQL SELECT and email the results. So far I have been using the Lambda Management Console, but all the examples I've run across talk about making a Lambda Deployment Package. So my first question is can I do this from the Lambda Management Console?



      Next question I have is what to import for the Oracle DB API? In all the examples I have seen, they download and build a package with pip, but that would then seem to imply using a Deployment Package (see above). Trying to import any of these modules listed in the examples simply give "No module named "...



      After writing the above I dug into the boto3 API referrence and came up with:



      import boto3
      client = boto3.client('rds-data')


      But it gives the error: Unknown service: 'rds-data'.



      So I'm still lost.



      As you can probably tell, I'm new to the Lambda environment. Any suggestions or examples would be greatly appreciated. Thanks.










      share|improve this question
















      I am writing (hopefully) a simply AWS Lambda that will do an RDS Oracle SQL SELECT and email the results. So far I have been using the Lambda Management Console, but all the examples I've run across talk about making a Lambda Deployment Package. So my first question is can I do this from the Lambda Management Console?



      Next question I have is what to import for the Oracle DB API? In all the examples I have seen, they download and build a package with pip, but that would then seem to imply using a Deployment Package (see above). Trying to import any of these modules listed in the examples simply give "No module named "...



      After writing the above I dug into the boto3 API referrence and came up with:



      import boto3
      client = boto3.client('rds-data')


      But it gives the error: Unknown service: 'rds-data'.



      So I'm still lost.



      As you can probably tell, I'm new to the Lambda environment. Any suggestions or examples would be greatly appreciated. Thanks.







      aws-lambda aws-sdk amazon-rds boto3






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 7 at 22:14







      wdtj

















      asked Mar 7 at 21:59









      wdtjwdtj

      15911




      15911






















          3 Answers
          3






          active

          oldest

          votes


















          1














          Apparently, AWS Lambda is using an older version of boto3, which does not have rds-data yet.



          So I'm afraid you will have to create a deployment package containing a more recent version of boto3.



          One way to do this, would be to:



          Create your lambda handler file (in this case named index.py).



          def my_handler(event, context):
          client = boto3.client('rds-data')
          print(client)
          # do stuff

          return "hello world"


          Add a requirements.txt file in the same folder, which will contain something like:



          awscli >= 1.16.118
          boto3 >= 1.9.108


          Now run this (depending on the setup on your computer, you can use pip instead of pip3) in the directory/folder of your index and requirement file:



          pip3 install -r requirements.txt -t . 
          zip -r somezipname .


          Next, upload this zip and change your handler 'entry point' to index.my_handler. The code should now run without errors.






          share|improve this answer























          • Got this working through to the point that we could connect to the database. At that point I get the error ERROR: invalid cluster id. After discussing this with Amazon support I get the impression that rds_data is only supported for Aurora. Trying cx_Oracle next. Thanks anyway.

            – wdtj
            Mar 11 at 14:23


















          1














          older version of boto3 does not support rds-data.
          but you can deploy package with zip folder.
          i recommend you to use import cx-oracle
          for that install cx-oracle using pip
          and upload zip packages. check this
          [How can I access Oracle from Python?






          share|improve this answer























          • Trying this (using the process suggested by Hieron) and your reference. It works fine when I run it locally, but when I try and run it as a Lambda I get "Unable to import module 'index': No module named 'cx_Oracle'"

            – wdtj
            Mar 11 at 14:25











          • may be this will help you stackoverflow.com/questions/40741282/…

            – primit patel
            Mar 12 at 4:58



















          0














          After much groaning and gnashing of teeth I have come up with a successful solution.



          rds_data (as confirmed by AWS Support) is only supporting Aurora Databases. Wish the AWS documents mentioned this. 8{(>



          Thanks to the answers above as well as Jason Landrey for hints as to the solution.



          In order to access RDS/Oracle, you need to use cx_Oracle. But wait, there's more.



          cx_Oracle is not in the standard Lambda environment, so you need to bring your own. My development environment is on Windows, but the Lambda environment is Linux. So, you need to download and install in your packaging directory I got mine from https://pypi.org/project/cx-Oracle/#files. Install locally with:



          pip install cx_Oracle-7.1.2-cp37-cp37m-manylinux1_x86_64.whl -t .


          You will see several file appear in . Then you need to find a Linux system and download /lib64/libaio.so.1.0.1 and call it libaio.so.1 in your packaging directory.

          And then you need to download both Oracle instant client basic and SDK packages from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html.



          Create a zip file with all these items (including your own Python source). In doing so, rename Oracle instant client files libclntsh.so.11.1 to libclntsh.so and libocci.so.11.1 to libocci.so.



          Upload the zip to a S3 bucket as the direct deploy is limited to 66mb and this zip is a bit larger.



          Create a Lambda with the appropriate IAM permissions and VPC access, install the package and it should be good to go.



          I found that if you don't include all the instant client files you start getting Oracle errors about missing timezone and NLS information.



          List of zip contents (for me, YMMV):



           7996693 08/24/2013 12:30 libnnz11.so
          0 03/11/2019 16:10 cx_Oracle-7.1.1.data/
          0 03/11/2019 16:10 cx_Oracle-7.1.1.data/data/
          0 03/11/2019 16:10 cx_Oracle-7.1.1.data/data/cx_Oracle-doc/
          0 03/11/2019 16:10 cx_Oracle-7.1.1.dist-info/
          1325 03/13/2019 12:35 Email.py
          1805 02/19/2019 21:11 cx_Oracle-7.1.1.data/data/cx_Oracle-doc/LICENSE.txt
          163 02/19/2019 21:11 cx_Oracle-7.1.1.data/data/cx_Oracle-doc/README.txt
          851 02/19/2019 21:11 cx_Oracle-7.1.1.dist-info/METADATA
          628 02/19/2019 21:12 cx_Oracle-7.1.1.dist-info/RECORD
          109 02/19/2019 21:12 cx_Oracle-7.1.1.dist-info/WHEEL
          10 02/19/2019 21:11 cx_Oracle-7.1.1.dist-info/top_level.txt
          2270301 02/19/2019 21:11 cx_Oracle.cpython-37m-x86_64-linux-gnu.so
          2140 03/13/2019 14:21 getSecrets.py
          5560 03/12/2019 08:48 libaio.so.1
          53865194 08/24/2013 12:30 libclntsh.so
          118738042 08/24/2013 12:30 libociei.so
          7633 03/13/2019 16:39 scheduleReports.py





          share|improve this answer

























          • If you're using a Wheel, then you shouldn't need the Oracle SDK header files since you aren't building any code. You can also delete JDBC libs, Java jars, and libocci. The Oracle doc somewhere has a list of the Instant Client files needed by C applications like cx_Oracle. Do you really need to use such an old version of Instant Client?

            – Christopher Jones
            Mar 14 at 1:14











          • I have tried removing libocci but get errors about not finding TZ and NLS files.

            – wdtj
            Mar 14 at 17:41











          • That sounds like you removed libociei.so, which is needed. Table 2-1 in the documentation lists the required libraries for OCI applications e.g. cx_Oracle or node-oracledb. If space is an issue, consider using the Basic Light package (see table 2.3)

            – Christopher Jones
            Mar 15 at 5:06












          • Aaah, thanks for the tip. Guess I didn't see that list since we're still on 11g. I'll update my solution.

            – wdtj
            Mar 15 at 16:02











          • Oracle client libraries 12.2 and 18c will connect to 11.2 DB. The new libraries do have useful improvements.

            – Christopher Jones
            Mar 16 at 22:54










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55053472%2faccessing-oracle-from-aws-lambda-in-python%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          3 Answers
          3






          active

          oldest

          votes








          3 Answers
          3






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          Apparently, AWS Lambda is using an older version of boto3, which does not have rds-data yet.



          So I'm afraid you will have to create a deployment package containing a more recent version of boto3.



          One way to do this, would be to:



          Create your lambda handler file (in this case named index.py).



          def my_handler(event, context):
          client = boto3.client('rds-data')
          print(client)
          # do stuff

          return "hello world"


          Add a requirements.txt file in the same folder, which will contain something like:



          awscli >= 1.16.118
          boto3 >= 1.9.108


          Now run this (depending on the setup on your computer, you can use pip instead of pip3) in the directory/folder of your index and requirement file:



          pip3 install -r requirements.txt -t . 
          zip -r somezipname .


          Next, upload this zip and change your handler 'entry point' to index.my_handler. The code should now run without errors.






          share|improve this answer























          • Got this working through to the point that we could connect to the database. At that point I get the error ERROR: invalid cluster id. After discussing this with Amazon support I get the impression that rds_data is only supported for Aurora. Trying cx_Oracle next. Thanks anyway.

            – wdtj
            Mar 11 at 14:23















          1














          Apparently, AWS Lambda is using an older version of boto3, which does not have rds-data yet.



          So I'm afraid you will have to create a deployment package containing a more recent version of boto3.



          One way to do this, would be to:



          Create your lambda handler file (in this case named index.py).



          def my_handler(event, context):
          client = boto3.client('rds-data')
          print(client)
          # do stuff

          return "hello world"


          Add a requirements.txt file in the same folder, which will contain something like:



          awscli >= 1.16.118
          boto3 >= 1.9.108


          Now run this (depending on the setup on your computer, you can use pip instead of pip3) in the directory/folder of your index and requirement file:



          pip3 install -r requirements.txt -t . 
          zip -r somezipname .


          Next, upload this zip and change your handler 'entry point' to index.my_handler. The code should now run without errors.






          share|improve this answer























          • Got this working through to the point that we could connect to the database. At that point I get the error ERROR: invalid cluster id. After discussing this with Amazon support I get the impression that rds_data is only supported for Aurora. Trying cx_Oracle next. Thanks anyway.

            – wdtj
            Mar 11 at 14:23













          1












          1








          1







          Apparently, AWS Lambda is using an older version of boto3, which does not have rds-data yet.



          So I'm afraid you will have to create a deployment package containing a more recent version of boto3.



          One way to do this, would be to:



          Create your lambda handler file (in this case named index.py).



          def my_handler(event, context):
          client = boto3.client('rds-data')
          print(client)
          # do stuff

          return "hello world"


          Add a requirements.txt file in the same folder, which will contain something like:



          awscli >= 1.16.118
          boto3 >= 1.9.108


          Now run this (depending on the setup on your computer, you can use pip instead of pip3) in the directory/folder of your index and requirement file:



          pip3 install -r requirements.txt -t . 
          zip -r somezipname .


          Next, upload this zip and change your handler 'entry point' to index.my_handler. The code should now run without errors.






          share|improve this answer













          Apparently, AWS Lambda is using an older version of boto3, which does not have rds-data yet.



          So I'm afraid you will have to create a deployment package containing a more recent version of boto3.



          One way to do this, would be to:



          Create your lambda handler file (in this case named index.py).



          def my_handler(event, context):
          client = boto3.client('rds-data')
          print(client)
          # do stuff

          return "hello world"


          Add a requirements.txt file in the same folder, which will contain something like:



          awscli >= 1.16.118
          boto3 >= 1.9.108


          Now run this (depending on the setup on your computer, you can use pip instead of pip3) in the directory/folder of your index and requirement file:



          pip3 install -r requirements.txt -t . 
          zip -r somezipname .


          Next, upload this zip and change your handler 'entry point' to index.my_handler. The code should now run without errors.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 8 at 10:21









          HieronHieron

          1217




          1217












          • Got this working through to the point that we could connect to the database. At that point I get the error ERROR: invalid cluster id. After discussing this with Amazon support I get the impression that rds_data is only supported for Aurora. Trying cx_Oracle next. Thanks anyway.

            – wdtj
            Mar 11 at 14:23

















          • Got this working through to the point that we could connect to the database. At that point I get the error ERROR: invalid cluster id. After discussing this with Amazon support I get the impression that rds_data is only supported for Aurora. Trying cx_Oracle next. Thanks anyway.

            – wdtj
            Mar 11 at 14:23
















          Got this working through to the point that we could connect to the database. At that point I get the error ERROR: invalid cluster id. After discussing this with Amazon support I get the impression that rds_data is only supported for Aurora. Trying cx_Oracle next. Thanks anyway.

          – wdtj
          Mar 11 at 14:23





          Got this working through to the point that we could connect to the database. At that point I get the error ERROR: invalid cluster id. After discussing this with Amazon support I get the impression that rds_data is only supported for Aurora. Trying cx_Oracle next. Thanks anyway.

          – wdtj
          Mar 11 at 14:23













          1














          older version of boto3 does not support rds-data.
          but you can deploy package with zip folder.
          i recommend you to use import cx-oracle
          for that install cx-oracle using pip
          and upload zip packages. check this
          [How can I access Oracle from Python?






          share|improve this answer























          • Trying this (using the process suggested by Hieron) and your reference. It works fine when I run it locally, but when I try and run it as a Lambda I get "Unable to import module 'index': No module named 'cx_Oracle'"

            – wdtj
            Mar 11 at 14:25











          • may be this will help you stackoverflow.com/questions/40741282/…

            – primit patel
            Mar 12 at 4:58
















          1














          older version of boto3 does not support rds-data.
          but you can deploy package with zip folder.
          i recommend you to use import cx-oracle
          for that install cx-oracle using pip
          and upload zip packages. check this
          [How can I access Oracle from Python?






          share|improve this answer























          • Trying this (using the process suggested by Hieron) and your reference. It works fine when I run it locally, but when I try and run it as a Lambda I get "Unable to import module 'index': No module named 'cx_Oracle'"

            – wdtj
            Mar 11 at 14:25











          • may be this will help you stackoverflow.com/questions/40741282/…

            – primit patel
            Mar 12 at 4:58














          1












          1








          1







          older version of boto3 does not support rds-data.
          but you can deploy package with zip folder.
          i recommend you to use import cx-oracle
          for that install cx-oracle using pip
          and upload zip packages. check this
          [How can I access Oracle from Python?






          share|improve this answer













          older version of boto3 does not support rds-data.
          but you can deploy package with zip folder.
          i recommend you to use import cx-oracle
          for that install cx-oracle using pip
          and upload zip packages. check this
          [How can I access Oracle from Python?







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 8 at 10:55









          primit patelprimit patel

          364




          364












          • Trying this (using the process suggested by Hieron) and your reference. It works fine when I run it locally, but when I try and run it as a Lambda I get "Unable to import module 'index': No module named 'cx_Oracle'"

            – wdtj
            Mar 11 at 14:25











          • may be this will help you stackoverflow.com/questions/40741282/…

            – primit patel
            Mar 12 at 4:58


















          • Trying this (using the process suggested by Hieron) and your reference. It works fine when I run it locally, but when I try and run it as a Lambda I get "Unable to import module 'index': No module named 'cx_Oracle'"

            – wdtj
            Mar 11 at 14:25











          • may be this will help you stackoverflow.com/questions/40741282/…

            – primit patel
            Mar 12 at 4:58

















          Trying this (using the process suggested by Hieron) and your reference. It works fine when I run it locally, but when I try and run it as a Lambda I get "Unable to import module 'index': No module named 'cx_Oracle'"

          – wdtj
          Mar 11 at 14:25





          Trying this (using the process suggested by Hieron) and your reference. It works fine when I run it locally, but when I try and run it as a Lambda I get "Unable to import module 'index': No module named 'cx_Oracle'"

          – wdtj
          Mar 11 at 14:25













          may be this will help you stackoverflow.com/questions/40741282/…

          – primit patel
          Mar 12 at 4:58






          may be this will help you stackoverflow.com/questions/40741282/…

          – primit patel
          Mar 12 at 4:58












          0














          After much groaning and gnashing of teeth I have come up with a successful solution.



          rds_data (as confirmed by AWS Support) is only supporting Aurora Databases. Wish the AWS documents mentioned this. 8{(>



          Thanks to the answers above as well as Jason Landrey for hints as to the solution.



          In order to access RDS/Oracle, you need to use cx_Oracle. But wait, there's more.



          cx_Oracle is not in the standard Lambda environment, so you need to bring your own. My development environment is on Windows, but the Lambda environment is Linux. So, you need to download and install in your packaging directory I got mine from https://pypi.org/project/cx-Oracle/#files. Install locally with:



          pip install cx_Oracle-7.1.2-cp37-cp37m-manylinux1_x86_64.whl -t .


          You will see several file appear in . Then you need to find a Linux system and download /lib64/libaio.so.1.0.1 and call it libaio.so.1 in your packaging directory.

          And then you need to download both Oracle instant client basic and SDK packages from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html.



          Create a zip file with all these items (including your own Python source). In doing so, rename Oracle instant client files libclntsh.so.11.1 to libclntsh.so and libocci.so.11.1 to libocci.so.



          Upload the zip to a S3 bucket as the direct deploy is limited to 66mb and this zip is a bit larger.



          Create a Lambda with the appropriate IAM permissions and VPC access, install the package and it should be good to go.



          I found that if you don't include all the instant client files you start getting Oracle errors about missing timezone and NLS information.



          List of zip contents (for me, YMMV):



           7996693 08/24/2013 12:30 libnnz11.so
          0 03/11/2019 16:10 cx_Oracle-7.1.1.data/
          0 03/11/2019 16:10 cx_Oracle-7.1.1.data/data/
          0 03/11/2019 16:10 cx_Oracle-7.1.1.data/data/cx_Oracle-doc/
          0 03/11/2019 16:10 cx_Oracle-7.1.1.dist-info/
          1325 03/13/2019 12:35 Email.py
          1805 02/19/2019 21:11 cx_Oracle-7.1.1.data/data/cx_Oracle-doc/LICENSE.txt
          163 02/19/2019 21:11 cx_Oracle-7.1.1.data/data/cx_Oracle-doc/README.txt
          851 02/19/2019 21:11 cx_Oracle-7.1.1.dist-info/METADATA
          628 02/19/2019 21:12 cx_Oracle-7.1.1.dist-info/RECORD
          109 02/19/2019 21:12 cx_Oracle-7.1.1.dist-info/WHEEL
          10 02/19/2019 21:11 cx_Oracle-7.1.1.dist-info/top_level.txt
          2270301 02/19/2019 21:11 cx_Oracle.cpython-37m-x86_64-linux-gnu.so
          2140 03/13/2019 14:21 getSecrets.py
          5560 03/12/2019 08:48 libaio.so.1
          53865194 08/24/2013 12:30 libclntsh.so
          118738042 08/24/2013 12:30 libociei.so
          7633 03/13/2019 16:39 scheduleReports.py





          share|improve this answer

























          • If you're using a Wheel, then you shouldn't need the Oracle SDK header files since you aren't building any code. You can also delete JDBC libs, Java jars, and libocci. The Oracle doc somewhere has a list of the Instant Client files needed by C applications like cx_Oracle. Do you really need to use such an old version of Instant Client?

            – Christopher Jones
            Mar 14 at 1:14











          • I have tried removing libocci but get errors about not finding TZ and NLS files.

            – wdtj
            Mar 14 at 17:41











          • That sounds like you removed libociei.so, which is needed. Table 2-1 in the documentation lists the required libraries for OCI applications e.g. cx_Oracle or node-oracledb. If space is an issue, consider using the Basic Light package (see table 2.3)

            – Christopher Jones
            Mar 15 at 5:06












          • Aaah, thanks for the tip. Guess I didn't see that list since we're still on 11g. I'll update my solution.

            – wdtj
            Mar 15 at 16:02











          • Oracle client libraries 12.2 and 18c will connect to 11.2 DB. The new libraries do have useful improvements.

            – Christopher Jones
            Mar 16 at 22:54















          0














          After much groaning and gnashing of teeth I have come up with a successful solution.



          rds_data (as confirmed by AWS Support) is only supporting Aurora Databases. Wish the AWS documents mentioned this. 8{(>



          Thanks to the answers above as well as Jason Landrey for hints as to the solution.



          In order to access RDS/Oracle, you need to use cx_Oracle. But wait, there's more.



          cx_Oracle is not in the standard Lambda environment, so you need to bring your own. My development environment is on Windows, but the Lambda environment is Linux. So, you need to download and install in your packaging directory I got mine from https://pypi.org/project/cx-Oracle/#files. Install locally with:



          pip install cx_Oracle-7.1.2-cp37-cp37m-manylinux1_x86_64.whl -t .


          You will see several file appear in . Then you need to find a Linux system and download /lib64/libaio.so.1.0.1 and call it libaio.so.1 in your packaging directory.

          And then you need to download both Oracle instant client basic and SDK packages from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html.



          Create a zip file with all these items (including your own Python source). In doing so, rename Oracle instant client files libclntsh.so.11.1 to libclntsh.so and libocci.so.11.1 to libocci.so.



          Upload the zip to a S3 bucket as the direct deploy is limited to 66mb and this zip is a bit larger.



          Create a Lambda with the appropriate IAM permissions and VPC access, install the package and it should be good to go.



          I found that if you don't include all the instant client files you start getting Oracle errors about missing timezone and NLS information.



          List of zip contents (for me, YMMV):



           7996693 08/24/2013 12:30 libnnz11.so
          0 03/11/2019 16:10 cx_Oracle-7.1.1.data/
          0 03/11/2019 16:10 cx_Oracle-7.1.1.data/data/
          0 03/11/2019 16:10 cx_Oracle-7.1.1.data/data/cx_Oracle-doc/
          0 03/11/2019 16:10 cx_Oracle-7.1.1.dist-info/
          1325 03/13/2019 12:35 Email.py
          1805 02/19/2019 21:11 cx_Oracle-7.1.1.data/data/cx_Oracle-doc/LICENSE.txt
          163 02/19/2019 21:11 cx_Oracle-7.1.1.data/data/cx_Oracle-doc/README.txt
          851 02/19/2019 21:11 cx_Oracle-7.1.1.dist-info/METADATA
          628 02/19/2019 21:12 cx_Oracle-7.1.1.dist-info/RECORD
          109 02/19/2019 21:12 cx_Oracle-7.1.1.dist-info/WHEEL
          10 02/19/2019 21:11 cx_Oracle-7.1.1.dist-info/top_level.txt
          2270301 02/19/2019 21:11 cx_Oracle.cpython-37m-x86_64-linux-gnu.so
          2140 03/13/2019 14:21 getSecrets.py
          5560 03/12/2019 08:48 libaio.so.1
          53865194 08/24/2013 12:30 libclntsh.so
          118738042 08/24/2013 12:30 libociei.so
          7633 03/13/2019 16:39 scheduleReports.py





          share|improve this answer

























          • If you're using a Wheel, then you shouldn't need the Oracle SDK header files since you aren't building any code. You can also delete JDBC libs, Java jars, and libocci. The Oracle doc somewhere has a list of the Instant Client files needed by C applications like cx_Oracle. Do you really need to use such an old version of Instant Client?

            – Christopher Jones
            Mar 14 at 1:14











          • I have tried removing libocci but get errors about not finding TZ and NLS files.

            – wdtj
            Mar 14 at 17:41











          • That sounds like you removed libociei.so, which is needed. Table 2-1 in the documentation lists the required libraries for OCI applications e.g. cx_Oracle or node-oracledb. If space is an issue, consider using the Basic Light package (see table 2.3)

            – Christopher Jones
            Mar 15 at 5:06












          • Aaah, thanks for the tip. Guess I didn't see that list since we're still on 11g. I'll update my solution.

            – wdtj
            Mar 15 at 16:02











          • Oracle client libraries 12.2 and 18c will connect to 11.2 DB. The new libraries do have useful improvements.

            – Christopher Jones
            Mar 16 at 22:54













          0












          0








          0







          After much groaning and gnashing of teeth I have come up with a successful solution.



          rds_data (as confirmed by AWS Support) is only supporting Aurora Databases. Wish the AWS documents mentioned this. 8{(>



          Thanks to the answers above as well as Jason Landrey for hints as to the solution.



          In order to access RDS/Oracle, you need to use cx_Oracle. But wait, there's more.



          cx_Oracle is not in the standard Lambda environment, so you need to bring your own. My development environment is on Windows, but the Lambda environment is Linux. So, you need to download and install in your packaging directory I got mine from https://pypi.org/project/cx-Oracle/#files. Install locally with:



          pip install cx_Oracle-7.1.2-cp37-cp37m-manylinux1_x86_64.whl -t .


          You will see several file appear in . Then you need to find a Linux system and download /lib64/libaio.so.1.0.1 and call it libaio.so.1 in your packaging directory.

          And then you need to download both Oracle instant client basic and SDK packages from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html.



          Create a zip file with all these items (including your own Python source). In doing so, rename Oracle instant client files libclntsh.so.11.1 to libclntsh.so and libocci.so.11.1 to libocci.so.



          Upload the zip to a S3 bucket as the direct deploy is limited to 66mb and this zip is a bit larger.



          Create a Lambda with the appropriate IAM permissions and VPC access, install the package and it should be good to go.



          I found that if you don't include all the instant client files you start getting Oracle errors about missing timezone and NLS information.



          List of zip contents (for me, YMMV):



           7996693 08/24/2013 12:30 libnnz11.so
          0 03/11/2019 16:10 cx_Oracle-7.1.1.data/
          0 03/11/2019 16:10 cx_Oracle-7.1.1.data/data/
          0 03/11/2019 16:10 cx_Oracle-7.1.1.data/data/cx_Oracle-doc/
          0 03/11/2019 16:10 cx_Oracle-7.1.1.dist-info/
          1325 03/13/2019 12:35 Email.py
          1805 02/19/2019 21:11 cx_Oracle-7.1.1.data/data/cx_Oracle-doc/LICENSE.txt
          163 02/19/2019 21:11 cx_Oracle-7.1.1.data/data/cx_Oracle-doc/README.txt
          851 02/19/2019 21:11 cx_Oracle-7.1.1.dist-info/METADATA
          628 02/19/2019 21:12 cx_Oracle-7.1.1.dist-info/RECORD
          109 02/19/2019 21:12 cx_Oracle-7.1.1.dist-info/WHEEL
          10 02/19/2019 21:11 cx_Oracle-7.1.1.dist-info/top_level.txt
          2270301 02/19/2019 21:11 cx_Oracle.cpython-37m-x86_64-linux-gnu.so
          2140 03/13/2019 14:21 getSecrets.py
          5560 03/12/2019 08:48 libaio.so.1
          53865194 08/24/2013 12:30 libclntsh.so
          118738042 08/24/2013 12:30 libociei.so
          7633 03/13/2019 16:39 scheduleReports.py





          share|improve this answer















          After much groaning and gnashing of teeth I have come up with a successful solution.



          rds_data (as confirmed by AWS Support) is only supporting Aurora Databases. Wish the AWS documents mentioned this. 8{(>



          Thanks to the answers above as well as Jason Landrey for hints as to the solution.



          In order to access RDS/Oracle, you need to use cx_Oracle. But wait, there's more.



          cx_Oracle is not in the standard Lambda environment, so you need to bring your own. My development environment is on Windows, but the Lambda environment is Linux. So, you need to download and install in your packaging directory I got mine from https://pypi.org/project/cx-Oracle/#files. Install locally with:



          pip install cx_Oracle-7.1.2-cp37-cp37m-manylinux1_x86_64.whl -t .


          You will see several file appear in . Then you need to find a Linux system and download /lib64/libaio.so.1.0.1 and call it libaio.so.1 in your packaging directory.

          And then you need to download both Oracle instant client basic and SDK packages from http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html.



          Create a zip file with all these items (including your own Python source). In doing so, rename Oracle instant client files libclntsh.so.11.1 to libclntsh.so and libocci.so.11.1 to libocci.so.



          Upload the zip to a S3 bucket as the direct deploy is limited to 66mb and this zip is a bit larger.



          Create a Lambda with the appropriate IAM permissions and VPC access, install the package and it should be good to go.



          I found that if you don't include all the instant client files you start getting Oracle errors about missing timezone and NLS information.



          List of zip contents (for me, YMMV):



           7996693 08/24/2013 12:30 libnnz11.so
          0 03/11/2019 16:10 cx_Oracle-7.1.1.data/
          0 03/11/2019 16:10 cx_Oracle-7.1.1.data/data/
          0 03/11/2019 16:10 cx_Oracle-7.1.1.data/data/cx_Oracle-doc/
          0 03/11/2019 16:10 cx_Oracle-7.1.1.dist-info/
          1325 03/13/2019 12:35 Email.py
          1805 02/19/2019 21:11 cx_Oracle-7.1.1.data/data/cx_Oracle-doc/LICENSE.txt
          163 02/19/2019 21:11 cx_Oracle-7.1.1.data/data/cx_Oracle-doc/README.txt
          851 02/19/2019 21:11 cx_Oracle-7.1.1.dist-info/METADATA
          628 02/19/2019 21:12 cx_Oracle-7.1.1.dist-info/RECORD
          109 02/19/2019 21:12 cx_Oracle-7.1.1.dist-info/WHEEL
          10 02/19/2019 21:11 cx_Oracle-7.1.1.dist-info/top_level.txt
          2270301 02/19/2019 21:11 cx_Oracle.cpython-37m-x86_64-linux-gnu.so
          2140 03/13/2019 14:21 getSecrets.py
          5560 03/12/2019 08:48 libaio.so.1
          53865194 08/24/2013 12:30 libclntsh.so
          118738042 08/24/2013 12:30 libociei.so
          7633 03/13/2019 16:39 scheduleReports.py






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 days ago

























          answered Mar 13 at 14:11









          wdtjwdtj

          15911




          15911












          • If you're using a Wheel, then you shouldn't need the Oracle SDK header files since you aren't building any code. You can also delete JDBC libs, Java jars, and libocci. The Oracle doc somewhere has a list of the Instant Client files needed by C applications like cx_Oracle. Do you really need to use such an old version of Instant Client?

            – Christopher Jones
            Mar 14 at 1:14











          • I have tried removing libocci but get errors about not finding TZ and NLS files.

            – wdtj
            Mar 14 at 17:41











          • That sounds like you removed libociei.so, which is needed. Table 2-1 in the documentation lists the required libraries for OCI applications e.g. cx_Oracle or node-oracledb. If space is an issue, consider using the Basic Light package (see table 2.3)

            – Christopher Jones
            Mar 15 at 5:06












          • Aaah, thanks for the tip. Guess I didn't see that list since we're still on 11g. I'll update my solution.

            – wdtj
            Mar 15 at 16:02











          • Oracle client libraries 12.2 and 18c will connect to 11.2 DB. The new libraries do have useful improvements.

            – Christopher Jones
            Mar 16 at 22:54

















          • If you're using a Wheel, then you shouldn't need the Oracle SDK header files since you aren't building any code. You can also delete JDBC libs, Java jars, and libocci. The Oracle doc somewhere has a list of the Instant Client files needed by C applications like cx_Oracle. Do you really need to use such an old version of Instant Client?

            – Christopher Jones
            Mar 14 at 1:14











          • I have tried removing libocci but get errors about not finding TZ and NLS files.

            – wdtj
            Mar 14 at 17:41











          • That sounds like you removed libociei.so, which is needed. Table 2-1 in the documentation lists the required libraries for OCI applications e.g. cx_Oracle or node-oracledb. If space is an issue, consider using the Basic Light package (see table 2.3)

            – Christopher Jones
            Mar 15 at 5:06












          • Aaah, thanks for the tip. Guess I didn't see that list since we're still on 11g. I'll update my solution.

            – wdtj
            Mar 15 at 16:02











          • Oracle client libraries 12.2 and 18c will connect to 11.2 DB. The new libraries do have useful improvements.

            – Christopher Jones
            Mar 16 at 22:54
















          If you're using a Wheel, then you shouldn't need the Oracle SDK header files since you aren't building any code. You can also delete JDBC libs, Java jars, and libocci. The Oracle doc somewhere has a list of the Instant Client files needed by C applications like cx_Oracle. Do you really need to use such an old version of Instant Client?

          – Christopher Jones
          Mar 14 at 1:14





          If you're using a Wheel, then you shouldn't need the Oracle SDK header files since you aren't building any code. You can also delete JDBC libs, Java jars, and libocci. The Oracle doc somewhere has a list of the Instant Client files needed by C applications like cx_Oracle. Do you really need to use such an old version of Instant Client?

          – Christopher Jones
          Mar 14 at 1:14













          I have tried removing libocci but get errors about not finding TZ and NLS files.

          – wdtj
          Mar 14 at 17:41





          I have tried removing libocci but get errors about not finding TZ and NLS files.

          – wdtj
          Mar 14 at 17:41













          That sounds like you removed libociei.so, which is needed. Table 2-1 in the documentation lists the required libraries for OCI applications e.g. cx_Oracle or node-oracledb. If space is an issue, consider using the Basic Light package (see table 2.3)

          – Christopher Jones
          Mar 15 at 5:06






          That sounds like you removed libociei.so, which is needed. Table 2-1 in the documentation lists the required libraries for OCI applications e.g. cx_Oracle or node-oracledb. If space is an issue, consider using the Basic Light package (see table 2.3)

          – Christopher Jones
          Mar 15 at 5:06














          Aaah, thanks for the tip. Guess I didn't see that list since we're still on 11g. I'll update my solution.

          – wdtj
          Mar 15 at 16:02





          Aaah, thanks for the tip. Guess I didn't see that list since we're still on 11g. I'll update my solution.

          – wdtj
          Mar 15 at 16:02













          Oracle client libraries 12.2 and 18c will connect to 11.2 DB. The new libraries do have useful improvements.

          – Christopher Jones
          Mar 16 at 22:54





          Oracle client libraries 12.2 and 18c will connect to 11.2 DB. The new libraries do have useful improvements.

          – Christopher Jones
          Mar 16 at 22:54

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55053472%2faccessing-oracle-from-aws-lambda-in-python%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

          Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

          2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived