Hi Eliot

you can try GraalVM’s polyglot capabilities: https://www.graalvm.org/22.0/reference-manual/embed-languages/

Or even try Jython. But you will run into problems if you need python libs that are not pure python.

regards
Stefan

From: BaseX-Talk <basex-talk-bounces@mailman.uni-konstanz.de> on behalf of Eliot Kimber <eliot.kimber@servicenow.com>
Sent: Sunday, January 22, 2023 5:43:44 PM
To: basex-talk@mailman.uni-konstanz.de <basex-talk@mailman.uni-konstanz.de>
Subject: [basex-talk] Integrating BaseX With Server-Side Python
 

I’ve started implementing some sophisticated DITA data processing in Python, including using the Python xlsxwriter to easily generate Excel spreadsheets, something that would be more work to add to BaseX using Java and the Apache POI libraries.

I’m also seeing that the Python streamlit tool, which provides sophisticated web pages for visualizing Python-based data (i.e., graphing from Pandas dataframes) would be a convenient way to generate graphs.

I’m wondering:

 

  1. Has anyone integrated streamlit with BaseX, for example, by running a streamlit server and using iframes from BaseX-served web pages to deliver graphs and whatnot. If so, are there any particular concerns or is it as simple running the server and creating the iframe?

  2. What would be the best way to run or access Python scripts from BaseX server, for example, to run a script that will generate an Excel sheet from some data on the server (or provided by BaseX in some convenient form) and then serve the generated result back out? I think it should be as easy as using the process module to run Python commands from the command line, but again, wondering if there are any non-obvious considerations?

 

Part of my new focus on Python is that my colleagues are Python-literate but not XQuery or XSLT literate, so it turns out to be best for us to do as much in Python as possible. But also the cost of doing really cool things in Python is just really low, streamlit being a good example.

 

Thanks,

 

E.

_____________________________________________

Eliot Kimber

Sr Staff Content Engineer

O: 512 554 9368

M: 512 554 9368

servicenow.com

LinkedIn | Twitter | YouTube | Facebook