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

grafik
Only this options will be available in LO with direct driver and connection to MariaDB through JDBC with mariadb-java-client-3.5.6.jar


This will be the default when connecting to MariaDB through JDBC directly, not by wizard “MySQL/MariaDB”.
grafik

This is the bare minimum, I expect from any type of database connection. It works with dBase, HSQL, H2. The same form does even work with spreadsheet data if you store the criteria on sheet. Firebird can do the same, if you know some tricks. I found at least one complex subform query where Firebird fails.
MariaDB can do the trick with JDBC, ODBC but not with SDBC.

What is SDBC?

SDBC (like “StarOffice”?) is the driver that is shipped with the office suite and which is supposed to work so well. You are confronted with this driver when you choose
menu:File>New>Database
Connect to existing “MySQL/MariaDB”

But as I understand it is no more :thinking:
Please review Connect to MariaDB
when I was unable to use this “default” option.

It should be removed!

Have no problem here with direct connection. Tested parameter and it works here. Setting up databases and it works also. Like the direct connection for PostgreSQL it should be the default - never removed. But some Linux distributions won’t install this driver by default.

SDBC with same database, same query and form:

The data content could not be loaded.
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘:pD1 IS NULL OR Date >= :pD1 ) AND ( :pD2 IS NULL OR Date <= :pD2 ) AND (…’ at line 1

With the most simple setup (Parent Field=Slave Field) I get the same error:

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘:link_from_TXT1 )’ at line 1

The obscure option "Replace parameters with ?" does not exist with this type of connection.
Built-in MySQL driver (SDBC)
Version: 25.8.3.2 (X86_64)
Build ID: 8ca8d55c161d602844f5428fa4b58097424e324e
CPU threads: 4; OS: Linux 5.15; UI render: Skia/Raster; VCL: x11
Locale: de-DE (de_DE.UTF-8); UI: en-US
Calc: threaded

Seems you got problems with LOWER ( "Name" ) LIKE LOWER ( CONCAT( '%', :qName, '%' ) ), but I couldn’t reproduce it in a query and couldn’t reproduce it in a form, which uses this query.

The option "Replace parameters with ?" is very old. It had been an option for every PostgreSQL-connection and every MySQL-connection when I created first Base Handbuch for LO 3.5 13 years ago. And it is the reason many people couldn’t get forms working with subforms. This option is also set in internal HSQLDB: db:parameter-name-substitution="false" (see content.xml) but would be ignored by HSQLDB. It is also a problem when migrating from HSQLDB to Firebird: Firebird reads this value “false” and subforms or parameterized queries won’t work with an automatic migrated database…

Even a trivial master-slave relation between two columns without any parameter fails. And as already said, the same query with the same form works with Maria over JDBC and ODBC and with any other type of database (backtick quotes replaced).

If you use the original packages from LO:
Open the Base file with a zip tool and have a look if db:parameter-name-substitution="false" appears.
This I could read in an older JDBC-connection for MariaDB/MySQL:

<db:driver-settings db:system-driver-settings="" db:base-dn="" db:parameter-name-substitution="false"/>

Might be it is set in your file also.
This I could read in a current file:

<db:driver-settings db:system-driver-settings="" db:base-dn=""/>

If there is any hint for parameter-name-substitution: Remove it.

Another very strange thing – this is the query source for my simulacrum of a monthly bank statement.
November

  • imes = 2025-11-01
  • fmes = 2025-11-30

If I enter the parameters ISO format query runs :ok: (of course).
If I enter in American format as per my locale here, query from “movimento” view runs, but subquery (that returns previous end of month balance to be added to running total in the report) does not run!
No need for the SUM() of course.
 
ISO
AmericanDate

I’think, we should avoid a general thread “all about databases” with the title "How to integrate a .py … "
Could you open a new topic for this.
.
I would suggest the same for the question, why sdbc is not working for @Villeroy, while others have no problem.

Why does Base create a document with parameter substitution disabled? Anyway, this off-topic problem is solved for me. I already knew that but forgot about it.

Well, how to integrate a Python/Beanshell/Javascript macro has been answered. I could not resist to mention:

before I realized that the default driver for MySQL does not seem to support the core functionality.

So this was kind of not off-topic :grinning:
And a new topic could be
Why does Base create a document with parameter substitution disabled?
 
But of course you’re right @Wanderer: I stop here.

Thanks guys. I really enjoyed this discussion.