<?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>question Re: NIFI Stored Procedure from Python Execute Script but getting error in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/NIFI-Stored-Procedure-from-Python-Execute-Script-but-getting/m-p/232477#M75122</link>
    <description>&lt;P&gt;Thanks &lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt;  I checked but issues is not with "print",  error due to "cx_Oracle" object.  Could you guide how i can run the my python code with &lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.5.0/org.apache.nifi.processors.standard.ExecuteProcess/index.html"&gt;ExecuteProcess&lt;/A&gt; or &lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.5.0/org.apache.nifi.processors.standard.ExecuteStreamCommand/index.html"&gt;ExecuteStreamCommand&lt;/A&gt; process? do you have configuration details ? &lt;/P&gt;</description>
    <pubDate>Thu, 01 Mar 2018 11:05:04 GMT</pubDate>
    <dc:creator>gkp_shakeel</dc:creator>
    <dc:date>2018-03-01T11:05:04Z</dc:date>
    <item>
      <title>NIFI Stored Procedure from Python Execute Script but getting error</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/NIFI-Stored-Procedure-from-Python-Execute-Script-but-getting/m-p/232475#M75120</link>
      <description>&lt;P&gt;Hi, I have written a simple python script to execute the oracle stored proc and its working when i executing using the python IDEL, when i am integrating in NIFI its giving error .&lt;/P&gt;&lt;P&gt;ERROR : SyntaxError: no viable alternative at input '\n' in &amp;lt;script&amp;gt; at line number 1 at column number 15; rolling back session: {}&lt;/P&gt;&lt;PRE&gt;
import sys 
import getpass 
import platform 
import cx_Oracle 
my_connection = cx_Oracle.connect('USer/Password@server.entsvcs.net:1526/database') 
my_cursor = my_connection.cursor() 
in_track_id='20585' 
in_username='A3843UP' 
in_course_no='00009934' 
my_cursor=my_connection.cursor() 
cur_var=my_cursor.var(cx_Oracle.CURSOR) 
cur_var1=my_cursor.var(cx_Oracle.NUMBER)
 cur_var2=my_cursor.var(cx_Oracle.STRING)
 my_cursor.callproc('sp_hp_course_status_chk', [in_track_id, in_username,in_course_no, cur_var,cur_var1,cur_var2]) 
print (cur_var.getvalue().fetchall()) 
print (int(cur_var1.getvalue())) 
print (cur_var2.getvalue())

#This code is working in python IDLE but getting error when adding in  NIFI&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="64430-configuration.jpg" style="width: 802px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/14834i0264154EB0522BEC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="64430-configuration.jpg" alt="64430-configuration.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="64429-errornifi.jpg" style="width: 1076px;"&gt;&lt;img src="https://community.cloudera.com/t5/image/serverpage/image-id/14835i9751B160F1406953/image-size/medium?v=v2&amp;amp;px=400" role="button" title="64429-errornifi.jpg" alt="64429-errornifi.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Aug 2019 00:25:27 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/NIFI-Stored-Procedure-from-Python-Execute-Script-but-getting/m-p/232475#M75120</guid>
      <dc:creator>gkp_shakeel</dc:creator>
      <dc:date>2019-08-18T00:25:27Z</dc:date>
    </item>
    <item>
      <title>Re: NIFI Stored Procedure from Python Execute Script but getting error</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/NIFI-Stored-Procedure-from-Python-Execute-Script-but-getting/m-p/232476#M75121</link>
      <description>&lt;P&gt;The scripting processors (ExecuteScript, e.g.) offer &lt;A href="http://www.jython.org/" target="_blank"&gt;Jython&lt;/A&gt;, not Python, as a scripting engine. Jython can't use compiled (CPython) modules, or modules whose dependencies include compiled modules. I suspect cx_Oracle or one of the other modules is (or depends on) compiled modules.&lt;/P&gt;&lt;P&gt;Since your script uses "print" rather than the NiFi API (see my &lt;A href="https://community.hortonworks.com/articles/75032/executescript-cookbook-part-1.html" target="_blank"&gt;ExecuteScript Cookbook&lt;/A&gt; for examples of the latter), you could use &lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.5.0/org.apache.nifi.processors.standard.ExecuteProcess/index.html" target="_blank"&gt;ExecuteProcess&lt;/A&gt; or &lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.5.0/org.apache.nifi.processors.standard.ExecuteStreamCommand/index.html" target="_blank"&gt;ExecuteStreamCommand&lt;/A&gt; to run your script using your native Python interpreter from the command line, the output will become the content of the flow file and should work for your use case.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Feb 2018 20:50:15 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/NIFI-Stored-Procedure-from-Python-Execute-Script-but-getting/m-p/232476#M75121</guid>
      <dc:creator>mburgess</dc:creator>
      <dc:date>2018-02-28T20:50:15Z</dc:date>
    </item>
    <item>
      <title>Re: NIFI Stored Procedure from Python Execute Script but getting error</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/NIFI-Stored-Procedure-from-Python-Execute-Script-but-getting/m-p/232477#M75122</link>
      <description>&lt;P&gt;Thanks &lt;A rel="user" href="https://community.cloudera.com/users/641/mburgess.html" nodeid="641"&gt;@Matt Burgess&lt;/A&gt;  I checked but issues is not with "print",  error due to "cx_Oracle" object.  Could you guide how i can run the my python code with &lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.5.0/org.apache.nifi.processors.standard.ExecuteProcess/index.html"&gt;ExecuteProcess&lt;/A&gt; or &lt;A href="https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-standard-nar/1.5.0/org.apache.nifi.processors.standard.ExecuteStreamCommand/index.html"&gt;ExecuteStreamCommand&lt;/A&gt; process? do you have configuration details ? &lt;/P&gt;</description>
      <pubDate>Thu, 01 Mar 2018 11:05:04 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/NIFI-Stored-Procedure-from-Python-Execute-Script-but-getting/m-p/232477#M75122</guid>
      <dc:creator>gkp_shakeel</dc:creator>
      <dc:date>2018-03-01T11:05:04Z</dc:date>
    </item>
    <item>
      <title>Re: NIFI Stored Procedure from Python Execute Script but getting error</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/NIFI-Stored-Procedure-from-Python-Execute-Script-but-getting/m-p/232478#M75123</link>
      <description>&lt;P&gt;Solved using the Groovy Code.  Hope it will help someone.. &lt;/P&gt;&lt;P&gt;Stored PROC using the following input and output&lt;/P&gt;&lt;P&gt; in_track_id       IN     NUMBER,&lt;BR /&gt;in_username       IN     VARCHAR2,&lt;BR /&gt;
   in_course_no      IN     VARCHAR2,&lt;BR /&gt;
   out_details          OUT SYS_REFCURSOR,&lt;BR /&gt;
   out_status_code      OUT NUMBER,&lt;BR /&gt;
   out_status_desc      OUT VARCHAR2)&lt;/P&gt;&lt;PRE&gt;import org.apache.commons.io.IOUtils
import org.apache.nifi.controller.ControllerService
import org.apache.nifi.processor.io.StreamCallback
import java.nio.charset.*
import groovy.sql.OutParameter
import groovy.sql.Sql
import oracle.jdbc.OracleTypes
import java.sql.ResultSet




//DB Setting Start
//Harcoded connection string
//def sql = Sql.newInstance('jdbc:oracle:thin:@//ecuxxx.xxx.xxx.net:1526/dbSchema', 'UserID', 'UserPass$', 'oracle.jdbc.OracleDriver')


//Get the conncation string from NIFI conncation pool
def lookup = context.controllerServiceLookup
def dbServiceName = ConncationPool.value
def dbcpServiceId = lookup.getControllerServiceIdentifiers(ControllerService).find {
    cs -&amp;gt; lookup.getControllerServiceName(cs) == dbServiceName
}


def conn = lookup.getControllerService(dbcpServiceId).getConnection();
sql = Sql.newInstance(conn);






////Get the session values from Nifi flow Start 
def flowFile = session.get()
if(!flowFile) return
in_track_id = flowFile.getAttribute('body_track_id')
in_username =  flowFile.getAttribute('body_username')
in_course_no = flowFile.getAttribute('body_course_number')
////Get the session values from Nifi flow END


// special OutParameter for cursor type
OutParameter CURSOR_PARAMETER = new OutParameter() {
    public int getType() {
        return OracleTypes.CURSOR;
    }
};
def data = []
// Stored proc having 3 input and 3 out put, one out put having CURSOR datatype
String sqlString ="""{call &amp;lt;StoredPrcoName&amp;gt;(?, ?, ?, ?, ?, ?)}""";
// rs contains the result set of cursor and data values start Shakeel
def  status_desc
def  status_code
def  status_data
//def parametersList = ['20585', 'A3843UP', '00009934', CURSOR_PARAMETER, Sql.NUMERIC ,Sql.VARCHAR]; // testing purpose
def parametersList = [in_track_id, in_username, in_course_no, CURSOR_PARAMETER, Sql.NUMERIC ,Sql.VARCHAR];


sql.call(sqlString, parametersList) {out_details, out_status_code,out_status_desc -&amp;gt;
    status_desc = out_status_desc
    status_code = out_status_code
    out_details.eachRow {
        data &amp;lt;&amp;lt; it.toRowResult()
        status_data = data
    }
};
// rs contains the result set of cursor and data values end


//Set the session values start 
def attrMap = ['status_desc':status_desc, 'status_code':String.valueOf(status_code),'status_data':String.valueOf(status_data),'Conn':String.valueOf(conn)]
flowFile = session.putAllAttributes(flowFile, attrMap)
session.transfer(flowFile, REL_SUCCESS)


&lt;/PRE&gt;</description>
      <pubDate>Fri, 16 Mar 2018 10:38:25 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/NIFI-Stored-Procedure-from-Python-Execute-Script-but-getting/m-p/232478#M75123</guid>
      <dc:creator>gkp_shakeel</dc:creator>
      <dc:date>2018-03-16T10:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: NIFI Stored Procedure from Python Execute Script but getting error</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/NIFI-Stored-Procedure-from-Python-Execute-Script-but-getting/m-p/358321#M75124</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.cloudera.com/t5/user/viewprofilepage/user-id/64857"&gt;@gkp_shakeel&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please help me with the CURSOR data type object and the&amp;nbsp;INTERFACE_DATA%ROWTYPE; Parameters. How can I call such store procedure&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Nov 2022 13:56:06 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/NIFI-Stored-Procedure-from-Python-Execute-Script-but-getting/m-p/358321#M75124</guid>
      <dc:creator>Techie123</dc:creator>
      <dc:date>2022-11-24T13:56:06Z</dc:date>
    </item>
  </channel>
</rss>

