[Python] Get SQL Select result in a variable

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
El Catala
Posts: 22
Joined: Mon Dec 07, 2020 6:29 pm

[Python] Get SQL Select result in a variable

Post by El Catala »

Hello,
How do you place in a variable, the result of a Select query contained in a Python script?
In traditional python, fetchall () does the birch well but in libre office, its not working!

Code: Select all

rqt = "SELECT * FROM Table1"
rslt = statement.excute(rqt)
In this case, a message box returns true
Each row in the table should normally be represented by a tuple in result.
So the problem I want to solve is to work on these tuples.
cordially
LibreOffice 7.0.4 Xubuntu 20.4
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Python]-Get SQL Select result in a variable

Post by Villeroy »

Lean how to use MRI or XRay. Inspect the statement. There is more than execute(sql).
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
El Catala
Posts: 22
Joined: Mon Dec 07, 2020 6:29 pm

Re: [Python]-Get SQL Select result in a variable

Post by El Catala »

Hello,

Thank you for your reply. It does not allow me to solve the problem. I wonder more and more whether it would not be better to give up Libre Office altogether.
As much as I was seduced by the python language which allows easy development, its integration into this office suite is catastrophic.
These words only represent my feelings and ask only to be contradicted. It's a shame because Libre Office could be a credible alternative to MS Office.
We must admit to the discharge of developers that the means are light years away from Microsoft !!!

Have a lovely day everybody
LibreOffice 7.0.4 Xubuntu 20.4
User avatar
Villeroy
Volunteer
Posts: 31269
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: [Python]-Get SQL Select result in a variable

Post by Villeroy »

Code: Select all

$ du -sh /opt/libreoffice7.1
678M	/opt/libreoffice7.1
678 MB including all the components, database drivers, a Basic runtime, a Python runtime. I would think that the footprint of VBA for MS Office Pro is on the same scale of magnitude. VBA is a very thick layer of software, like a second office suite with a CLI instead of the GUI.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply