Support Questions

Find answers, ask questions, and share your expertise

NIFI -- How to import python libs for ExecuteScript

avatar
Rising Star

Hi all,

I am using Python ExecuteScript in Apache NiFi to list all Databases name in Mongo then load all tables name in Mongo, however, they dont have lib mongo. Do you know How to import python libs for ExecuteScript?

Or any suggestions to load all Databases name and tables name in Mongo in Nifi

Many thanks

4 REPLIES 4

avatar
Master Mentor

@Thuy Le

-

Does your Python script execute fine via command line on your NiFi servers?

If so, did you consider instead just using the ExecuteStreamCommand processor to execute your script? This will behave in same way as executing yourself form command line and will not rely on NiFi built in libs.

-

The latest version of NiFi contain numerous mongo specific processors. I am not a Mongo user myself, but have you looked to see if any of those would meet the needs of your dataflow here?

-

Thank you,

Matt

-

If you found this answer addressed your question, please take a moment to login in and click the "ACCEPT" link.

avatar
Master Guru

If the "mongo" library contains native Python (CPython) code or dependencies, you can't use them in ExecuteScript (which uses Jython not Python). See Matt C's answer for a workaround to use actual Python.

avatar
Rising Star

Hi Matt, thanks for your answers, do you think Mongo is native in Groovy or JavaScript?

Thanks

avatar
Master Guru

There is a mongo-java-driver you can use in either Groovy or Javascript (or any of the scripted languages in ExecuteScript), check my blog on how to use modules.