Member since
05-30-2023
45
Posts
4
Kudos Received
0
Solutions
09-01-2023
01:44 AM
I am trying to make a conenction to my Sql Server using "zxJDBC". Below is my code in ExecuteScript processor: from com.ziclix.python.sql import zxJDBC d, u, p, v = "jdbc:sqlserver://<servername>;Database=<databasename>;encrypt=true;trustServerCertificate=true;user=<username>;password=<password>;integratedSecurity=true", None, None, " com.microsoft.sqlserver.jdbc.SQLServerDriver" db = zxJDBC.connect(d, u, p, v) c = db.cursor() However, I am getting an error " zxjdbc.database error driver com.microsoft.sqlserver.jdbc.SQLServerDriver not found" My limted research in internet found out that it is dependent on some jar files how how can we add jar files classpath in nifi processors. Please guide in making this Sql server connection successful. Thanks.
... View more
Labels:
- Labels:
-
Apache NiFi
-
NiFi Registry
08-31-2023
08:17 AM
@SAMSAL, hey I know I accepted the solution and it did work for when I had 1 user details to fetch and store it's values to the processor's attributes. I wanted to ask if it is possible to store multiple values to a single attribute of a processor since I now have many users' details to store. Is this possible otherwise I would have to change the logic? Thanks.
... View more
08-30-2023
02:57 AM
1 Kudo
Yes, I ended up changing my ExecuteScript in a way that all column's values are now attributes of my flowFile. Next, I have added PutSql processor and inserting data using ${attributename}. Thanks @SAMSAL for responding.
... View more
08-29-2023
01:30 PM
Thanks @SAMSAL for responding. I will explain what I am trying to accomplish. The ExecuteStreamCommand gives me below results: and I want to use displayName and mail key's values from this result and store it into the database. My current workflow is based on the flow that I will store these two key's value as a attribute and use it in the subsequent processors. However, using AttributestoJson aint also working for me. Can you suggest any other better appraoach to ingest these two values in my database? I have other columns' value to ingest that as well so may be ExecuteSQLCommand processor would be a better choice to use.
... View more
08-29-2023
08:39 AM
Can you help me with a similar issue? My code: import json import collections import java.io import ast from org.apache.commons.io import IOUtils from java.nio.charset import StandardCharsets from org.apache.nifi.processor.io import StreamCallback class ModJSON(StreamCallback) : def __init__(self): pass def process(self, inputStream, outputStream): text = IOUtils.toString(inputStream, StandardCharsets.UTF_8) obj = ast.literal_eval(text) mail = obj['mail'] outputStream.write(bytearray(json.dumps(obj['mail'], indent=4).encode('utf-8'))) outputStream.write(bytearray(json.dumps(obj['id'], indent=4).encode('utf-8'))) flowFile = session.get() if (flowFile != None): flowFile = session.write(flowFile, ModJSON()) flowFile = session.putAttribute(flowFile, "filename", flowFile.getAttribute('filename').split('.')[0]+'_translated.json') flowFile = session.putAttribute(flowFile, "mail", mail) session.transfer(flowFile, REL_SUCCESS) session.commit() I want to get "mail" value and create a new attribute for it. However, mail variable is not accessible when I insert it into the putattribute command. Any feedback?
... View more
08-29-2023
03:20 AM
I am executing python script in ExecuteStreamCommand and my code last line dumps the json key values. My goal is to read those key values into PutDatabaseRecord processor and insert the values in my database. However, I am unable to read content of the flow file of ExecuteStream. I have used ConvertAvrotoJson but it is showing output as "not a avro data file". Is there any workarounf of it? Thanks.
... View more
Labels:
- Labels:
-
Apache NiFi
-
NiFi Registry
08-28-2023
07:50 AM
Thanks for the reply. I did it in the same way you have mentioned (I am importing Selenium module and from this module, Service, WebDriverWait and EC components are imported) but late in the code execution, my scripts gives an error "global name Service is not defined". Any idea whats causing the issue?
... View more
08-28-2023
07:07 AM
@joseomjr I am trying to replicate your suggested method, please answer did you include the import command after sys.path.append command?
... View more
08-28-2023
06:29 AM
I want to run python script using ExecuteScript processor and my script has Selenium module to refer to as well. The Selenium module is written in Python language and I believe, it should run in the processor. Below are few lines of code depicting how I have added the modules: import sys sys.path.append(r"C:/Python311/Lib/site-packages/selenium/") sys.path.append(r"C:/Python311/Lib/site-packages/requests/") from org.apache.commons.io import IOUtils from java.nio.charset import StandardCharsets from org.apache.nifi.processor.io import StreamCallback Notice that after appending module in the path, I am not using "from module_name import.." command. However, in the code, the modules are not being fetched and it gives me error. Any help is appreciated.
... View more
Labels:
- Labels:
-
Apache NiFi
08-17-2023
04:49 AM
1 Kudo
Thanks. It was an issue with the connection string. It was pointing to another database while my processor was inserting into another database.
... View more