<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic cx_Oracle import problem in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/cx-Oracle-import-problem/m-p/350534#M5580</link>
    <description>&lt;P&gt;Hello Splunkers.&lt;/P&gt;

&lt;P&gt;I wrote two python scripts to use in my environment as scripted-lookups: one of them makes a query in an Oracle database, while the other do some math checks.&lt;BR /&gt;
The second works perfectly, but not the first.&lt;/P&gt;

&lt;P&gt;I noticed that the problem with the first script resides on &lt;STRONG&gt;cx_Oracle&lt;/STRONG&gt; module.&lt;BR /&gt;
When I run my script with pure python, I can import the module:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4800i6F03D0B7335D5BD9/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;When I run with the splunk python, I get the following error:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4801i3F23A7EFA58C589D/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Has anyone ever experienced this?&lt;BR /&gt;
Can you tell me step by step how to get around this problem?&lt;/P&gt;

&lt;P&gt;Thanks in advance!&lt;BR /&gt;
Regards, GMA&lt;/P&gt;</description>
    <pubDate>Thu, 19 Apr 2018 14:46:58 GMT</pubDate>
    <dc:creator>guimilare</dc:creator>
    <dc:date>2018-04-19T14:46:58Z</dc:date>
    <item>
      <title>cx_Oracle import problem</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/cx-Oracle-import-problem/m-p/350534#M5580</link>
      <description>&lt;P&gt;Hello Splunkers.&lt;/P&gt;

&lt;P&gt;I wrote two python scripts to use in my environment as scripted-lookups: one of them makes a query in an Oracle database, while the other do some math checks.&lt;BR /&gt;
The second works perfectly, but not the first.&lt;/P&gt;

&lt;P&gt;I noticed that the problem with the first script resides on &lt;STRONG&gt;cx_Oracle&lt;/STRONG&gt; module.&lt;BR /&gt;
When I run my script with pure python, I can import the module:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4800i6F03D0B7335D5BD9/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;When I run with the splunk python, I get the following error:&lt;/P&gt;

&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/4801i3F23A7EFA58C589D/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Has anyone ever experienced this?&lt;BR /&gt;
Can you tell me step by step how to get around this problem?&lt;/P&gt;

&lt;P&gt;Thanks in advance!&lt;BR /&gt;
Regards, GMA&lt;/P&gt;</description>
      <pubDate>Thu, 19 Apr 2018 14:46:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/cx-Oracle-import-problem/m-p/350534#M5580</guid>
      <dc:creator>guimilare</dc:creator>
      <dc:date>2018-04-19T14:46:58Z</dc:date>
    </item>
    <item>
      <title>Re: cx_Oracle import problem</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/cx-Oracle-import-problem/m-p/350535#M5581</link>
      <description>&lt;P&gt;You can refer db_connect app and look at db_lookup() script. Also this answer may help:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/2580/i-want-sample-code-to-connect-to-oracle-database-and-lookup-a-table-at-search-time.html" target="_blank"&gt;https://answers.splunk.com/answers/2580/i-want-sample-code-to-connect-to-oracle-database-and-lookup-a-table-at-search-time.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 19:05:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/cx-Oracle-import-problem/m-p/350535#M5581</guid>
      <dc:creator>p_gurav</dc:creator>
      <dc:date>2020-09-29T19:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: cx_Oracle import problem</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/cx-Oracle-import-problem/m-p/350536#M5582</link>
      <description>&lt;P&gt;guimilare,&lt;BR /&gt;
Splunk ships with it's own Python environment. This means if you're running a Python script you'd need to have the module you'd like to import in the current working directory. For more on how Python imports work, this blog post seems helpful: &lt;A href="https://leemendelowitz.github.io/blog/how-does-python-find-packages.html"&gt;https://leemendelowitz.github.io/blog/how-does-python-find-packages.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I'd also say, do NOT modify Splunk's python modules. It's not supported to install additional modules into Splunk's python environment. You should be putting the modules next to the python script you're trying to run.&lt;/P&gt;

&lt;P&gt;All that said, I will echo what p_gurav said - If you're trying to import data from a database directly, you're probably best off utilizing Splunk DB Connect. &lt;A href="https://splunkbase.splunk.com/app/2686/"&gt;https://splunkbase.splunk.com/app/2686/&lt;/A&gt;&lt;BR /&gt;
Specifically for a lookup: &lt;A href="http://docs.splunk.com/Documentation/DBX/3.1.3/DeployDBX/Createandmanagedatabaselookups"&gt;http://docs.splunk.com/Documentation/DBX/3.1.3/DeployDBX/Createandmanagedatabaselookups&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Apr 2018 21:30:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/cx-Oracle-import-problem/m-p/350536#M5582</guid>
      <dc:creator>beatus</dc:creator>
      <dc:date>2018-04-20T21:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: cx_Oracle import problem</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/cx-Oracle-import-problem/m-p/350537#M5583</link>
      <description>&lt;P&gt;So, here is the roadmap to correctly install cx_Oracle:&lt;/P&gt;

&lt;P&gt;The first task is installing the Oracle client.&lt;BR /&gt;
It is important that the client version is 11.2. &lt;BR /&gt;
In higher versions, the cx_Oracle connector does not work correctly.&lt;/P&gt;

&lt;P&gt;1) From the &lt;A href="http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html" target="_blank"&gt;http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html&lt;/A&gt; page, download the following executables: &lt;/P&gt;

&lt;P&gt;&lt;EM&gt;instantclient-basic-linux.x64-11.2.0.4.0.zip&lt;BR /&gt;
instantclient-sqlplus-linux.x64-11.2.0.4.0.zip&lt;BR /&gt;
instantclient-sdk-linux.x64-11.2.0.4.0.zip&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;2) In the &lt;EM&gt;/opt/splunk&lt;/EM&gt; folder, unzip the files&lt;/P&gt;

&lt;P&gt;3) Configure oracle env:&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;vim /etc/profile.d/oracle.sh&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;#! / bin / bash &lt;BR /&gt;
LD_LIBRARY_PATH = "/usr/lib/oracle/11.2/client64/lib:${LD_LIBRARY_PATH}" &lt;BR /&gt;
export LD_LIBRARY_PATH &lt;BR /&gt;
TNS_ADMIN = "/etc/oracle" &lt;BR /&gt;
export TNS_ADMIN &lt;BR /&gt;
ORACLE_HOME = "/usr/lib oracle/11.2/client64/lib" &lt;BR /&gt;
export ORACLE_HOME&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;4) Environment variables:&lt;BR /&gt;
&lt;EM&gt;source /etc/profile.d/oracle.sh&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;5) Copy or create the tnsnames.ora:&lt;BR /&gt;
&lt;EM&gt;touch /etc/oracle/tnsnames.ora&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;6) Create symbolic link to ORACLE_HOME to avoid the "can not locate Oracle include files" error:&lt;BR /&gt;
&lt;EM&gt;mkdir /usr/lib/oracle/11.2/client64/lib/sdk&lt;BR /&gt;
ln -s /usr/include/oracle/11.2/client64 /usr/lib/oracle/11.2/client64/lib/sdk/include&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;The next step is to install the cx_Oracle connector.&lt;BR /&gt;
Download cx_Oracle version 5.1.2 from &lt;A href="https://sourceforge.net/projects/cx-oracle/files/5.1.2/cx_Oracle-5.1.2-11g-py26-1.x86_64.rpm/download" target="_blank"&gt;https://sourceforge.net/projects/cx-oracle/files/5.1.2/cx_Oracle-5.1.2-11g-py26-1.x86_64.rpm/download&lt;/A&gt; and install the RPM.&lt;/P&gt;

&lt;P&gt;It is possible that when importing the cx_Oracle library, the following error occurs:&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;Traceback (most recent call last):&lt;BR /&gt;
    import cx_Oracle&lt;BR /&gt;
ImportError: libclntsh.so.11.1: Can not open shared object file: No such file or directory&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;To bypass this, create the following symbolic links (the paths to the files may change depending on the environment and where the files were extracted. Run find / -name lib * .so * to find the correct path):&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;/usr/lib64/libclntsh.so.11.1 → /usr/lib/oracle/11.2/client64/lib/libclntsh.so.11.1&lt;BR /&gt;
/usr/lib64/libnnz11.so → /usr/lib/oracle/11.2/client64/lib/libnnz11.so&lt;BR /&gt;
/usr/lib64/libocci.so.11.1 → /usr/lib/oracle/11.2/client64/lib/libocci.so.11.1&lt;BR /&gt;
/usr/lib64/libociei.so → /usr/lib/oracle/11.2/client64/lib/libociei.so&lt;BR /&gt;
/usr/lib64/libsqlplusic.so → /usr/lib/oracle/11.2/client64/lib/libsqlplusic.so&lt;BR /&gt;
/usr/lib64/libsqlplus.so → /usr/lib/oracle/11.2/client64/lib/libsqlplus.so&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;Now the environment is ready. To test, simply execute the commands below:&lt;/P&gt;

&lt;P&gt;&lt;EM&gt;[splunk @ splunktest-01 ~] $ python&lt;BR /&gt;
Python 2.6.6 (r266: 84292, Sep 4 2013, 07:46:00)&lt;BR /&gt;
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2&lt;BR /&gt;
Type "help", "copyright", "credits" or "license" for more information.&lt;BR /&gt;
&amp;gt;&amp;gt;&amp;gt; import cx_Oracle&lt;BR /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;/EM&gt;&lt;/P&gt;

&lt;P&gt;If no error are displayed, the environment is correctly set up.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:58:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/cx-Oracle-import-problem/m-p/350537#M5583</guid>
      <dc:creator>guimilare</dc:creator>
      <dc:date>2020-09-29T20:58:07Z</dc:date>
    </item>
  </channel>
</rss>

