How do you integrate a .py file or a Python script into a .odb file?

Is Python really the recommended programming language for LibreOffice?
.
Disappointing observation and personal impression…
.

**Functionality      Basic   Python**
Integrated Editor:   Yes     No
Macros Creation:     Yes     No
Modification:        Yes     No
Debugging:           Yes     No
Base Integration:    Yes     No (completely incomplete)
Portability          ?       ?

.
This is objectively absurd for a language supposedly favored and recommended by the community…
.

No. It is one of many possible languages. Libre/Open/Staroffice has an API to be used also from Java, C++, Netbeans, JavaSript etc.
.
When StarOffice was created an Office Suite should have BASIC available for scripting, so that’s the one where you find most macros.
.
Today LibreOffice ships with BASIC, an integrated Python (on Linux mostly replaced by system python,) and a JavaScript Interpreter.
Use APSO to manage your Python macros.
.
You could also say C++ is the recommend language or Java. Use what suits your need. Your first question should be Interpreter or Compiler. The find out how to use it.
.
Imho for a lot of macros the language is not important, only the API is…

2 Likes

For integrating a python script to a Base file you will need a zip-app or
APSO. With APSO you could copy the file, which is stored in the python path of LO, to the database file.

The recommended programming language is Basic. There is an integrated editor so you could test all you have programmed directly and get feedback directly when code isn’t working well. It will show the “wrong” row and also a message what is wrong there.

If you know more about Python like I know it might be easy to write code without testing.

Thank you, I wanted to explore Python, but I found the integration with LibreOffice to be completely lacking. APSO seems like an interesting alternative. I also agree with you that a good understanding of APIs makes all the difference.

I usually use StarBasic, but I wanted to explore Python on both Linux and Windows, I realize I will need a folder that contains my Python scripts available on both platforms so that I can copy/paste them to the accessible location where LibreOffice expects to find them.

more exactly its THE tool for organizing, debugging and installing python–scripts both on windows and linux.
to explore the API you should use mri.oxt
as IDE you may choose any of simple editors like ( notepad, geany ect.) or full featured like ( VSCode, PyCharm …)

I myself enjoy working in a interactive Jupyter Notebook session, from which I can solve most of the tasks mentioned above.

I have not been able to pass parameters to queries for MariaDB’s connection.
As an exercise will try installing APSO in another (dummy) connection and construct a prepared statement using Python.
And try integrate it to the .odb of course.
But it’ll demand time…