Connection from python to firebird database embedded in libreoffice base

Hi, I have a libreoffice base database with firebird embedded. I am needing to be able to access from python to that database to be able to access records, read and write to the database. I need to connect the database with embedded firebird to other applications and for this I use python. Any help? thank you very much.

Diego

Hello,
Do know you can access embedded Firebird & HSQLDB databases from within LO. Do not think there is a way to access these from outside of LO. For that you would likely need a server such as Firebird, PostgreSQL, MySQL etc.

I have seen this example with the orm and I thought it could be Apache OpenOffice: Foro oficial de la comunidad - Base, Firebird y ORM - (Ver Tema) but I have not been able to install the python easymacro and LOBaseDatabase modules to make the python program work.

Still unclear as that post talks a lot of connection to servers. The one brief mention (it appears) with embedded is within LO and an embedded DB. You have not made clear what ...other applications... actually are.
.
It would appear with that it is something other than LO.
.
If you are dealing with a connection within LO, post a sample of the code you are having issues with.
.
Edit:
.
See easymacro

@dcapeletti,
Again from within LO, here is a link with some connections I have used before:

Python programming in LibreOffice is very dependent on your operating system. Without knowing what OS you have and what versions of LibreOffice we are left to guess, and I am very bad at guessing.

Yes, it is possible to connect to Base(Firebird) from inside and outside LibreOffice.

I have reviewed the 2019 code and it still works, but, I will refactor it.

import easymacro as app
from zazplus.peewee import *
from zazplus import easyplus


database_proxy = DatabaseProxy()


class BaseModel(Model):
    class Meta:
        database = database_proxy


class Person(BaseModel):
    id = IdentityField()
    name = CharField()
    last_name = CharField()


def main():
    PATH_DB = '/home/mau/people.odb'
    db = easyplus.LODocBase(PATH_DB)
    db.initialize(database_proxy, [Person])

    p = Person(name='Teresa', last_name='Salgueiro')
    p.save()
    Person.insert(name='Naomi', last_name='Watts').execute()

    db.close()

    app.debug('ok')
    return

Work fine.

soffice --calc
22/05/2022 23:17:09 - DEBUG - CREATE TABLE "person" ("id" INT GENERATED BY DEFAULT AS IDENTITY NOT NULL PRIMARY KEY, "name" VARCHAR(255) NOT NULL, "last_name" VARCHAR(255) NOT NULL)	[]
22/05/2022 23:17:09 - DEBUG - INSERT INTO "person" ("name", "last_name") VALUES (?, ?)	['Teresa', 'Salgueiro']
22/05/2022 23:17:09 - DEBUG - INSERT INTO "person" ("name", "last_name") VALUES (?, ?)	['Naomi', 'Watts']
22/05/2022 23:17:09 - DEBUG - ok

Result.

image

PLEASE. Do not attempt to use until fully documented, thank you.

Hi I am using Debian 11, python3 and LibreOffice:
Version: 7.1.5.2 / LibreOffice Community
Build ID: 85f04e9f809797b8199d13c421bd8a2b025d52b5
CPU threads: 4; OS: Linux 5.10; UI render: default; VCL: gtk3
Locale: es-AR (es_AR.UTF-8); UI: es-ES
Calc: threaded

I would like to be able to access my embedded firebird database to read tables, create and query records from my python application. what steps do i need to do?

Thanks

I have run this code and the python output is as follows:

Traceback (most recent call last):
File “/home/dcapeletti/Documentos/python-libreoffice/pruebasDb.py”, line 1, in
import easymacro as app
File “/usr/lib/python3.9/easymacro.py”, line 351, in
LANGUAGE = get_app_config(‘org.openoffice.Setup/L10N/’, ‘ooLocale’)
File “/usr/lib/python3.9/easymacro.py”, line 338, in get_app_config
cp = create_instance(name, True)
File “/usr/lib/python3.9/easymacro.py”, line 327, in create_instance
instance = SM.createInstanceWithContext(name, CTX)
easymacro.CannotActivateFactoryException: loading component library <file:///usr/lib/libreoffice/program/libmergedlo.so> failed ./cppuhelper/source/shlib.cxx:298

If I need to change anything to make it work, let me know. Thanks

@dcapeletti
Have given you the link to get easymacro library above in my second comment under Edit about 6 days ago. For what you have presented that is at least part of what is needed to be installed.

Please, I am refactoring all the code, at the moment, you only get errors and frustration. You must wait for me to finish.