Re: Anyone know how to configure the Python Firebird-Driver???

340 views
Skip to first unread message

Steve Naidamast

unread,
Jul 2, 2022, 6:18:22 PM7/2/22
to firebird-support
Hello...

I have been working with the Firebird Embedded Database Engine for quite a while now.

As a result, I have wanted to continue using it with a  conversion of an application of mine to Python.  So far, I am getting the hang of Python fairly well.

However, using JetBrains PyCharm IDE, which I like, and having installed the latest Firebird-Driver from the referenced link on the Firebird website, I have yet to be able to connect to my database file.

No matter how I try to configure this driver, I continuously get the error: "The location of Firebird Client Library could not be determined"

I have gone into the Firebird-Driver code and tracked how the driver is processing the search for the "fbclient.dll".  As a result, I add the path to the os.eviron['PATH'] variable where my Firebird assemblies are.  But no luck.

I have also researched the configuration classes as well and have made some successful manipulations of these classes but still no luck.

Since I am still learning Python and the documentation for this driver is mostly API documentation, I found it rather unclear how one is supposed to make such updates.

Can anyone demonstrate to me how this driver should be configured properly to get it working within the Python environment?

Any assistance would be greatly appreciated.

Thank you...

Mark Rotteveel

unread,
Jul 3, 2022, 3:42:04 AM7/3/22
to firebird...@googlegroups.com
Your question would be more suitable for the firebird-python Google
Group (https://groups.google.com/g/firebird-python). It is not a very
active group, but it should be the right place for your question.

In any case, to your question:

As far as I'm aware, you cannot add things to the PATH at runtime, you
need to do that before launching the application (or at least, I think
modifying the value in os.eviron["PATH"] will not have any effect). Also
make sure you use a fbclient.dll of the right bitness (if you're Python
is 64-bit, you need a 64-bit fbclient.dll, if 32-bit, then 32-bit).

Instead of fiddling with the PATH, you can also do a (minimal) client
install using the installer (which will install in %windir%\system32 (or
SysWOW64), which is usually already on the PATH). You should also be
able to specify the driver with config option fb_client_library, see
https://firebird-driver.readthedocs.io/en/latest/usage-guide.html#the-driver-config-object
:

"""
If you want to use specific Firebird client library, you must set the
value of DriverConfig.fb_client_library configuration option before your
application calls any from following functions: connect(),
create_database(), connect_server(), load_api() or get_api().
"""

Mark
> --
> You received this message because you are subscribed to the Google
> Groups "firebird-support" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to firebird-suppo...@googlegroups.com
> <mailto:firebird-suppo...@googlegroups.com>.
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/firebird-support/0d6b900a-a4a4-4845-90a3-975f19a711fan%40googlegroups.com
> <https://groups.google.com/d/msgid/firebird-support/0d6b900a-a4a4-4845-90a3-975f19a711fan%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Mark Rotteveel

Steve Naidamast

unread,
Jul 3, 2022, 10:10:33 AM7/3/22
to firebird-support
Thank you, Mark, for your notes.

What you describe does not appear to be beneficial for developers who want to package the Firebird Embedded Database Engine with their applications.

It leads to me to the question as why the Firebird-Driver author would make something so simple yet so complex by not using an easily modifiable configuration file.

In any event, I have tried various uses of the fb_client_library configuration, none of which have worked so far...

Steve Naidamast

Mark Rotteveel

unread,
Jul 3, 2022, 10:59:24 AM7/3/22
to firebird...@googlegroups.com
On 03-07-2022 16:10, Steve Naidamast wrote:
> Thank you, Mark, for your notes.
>
> What you describe does not appear to be beneficial for developers who
> want to package the Firebird Embedded Database Engine with their
> applications.

I don't see why not. You should be able to configure it through
driver_config.fb_client_library (you may need an explicit import from
firebird.driver.config, my Python is a bit rusty), or otherwise
configure the PATH in the start-up script of your application.

> It leads to me to the question as why the Firebird-Driver author would
> make something so simple yet so complex by not using an easily
> modifiable configuration file.

Please ask this question on firebird-python, or create an issue on
https://github.com/FirebirdSQL/python3-driver

> In any event, I have tried various uses of the fb_client_library
> configuration, none of which have worked so far...

See above.

Also, it would be helpful to show *what* you tried.

Mark
--
Mark Rotteveel

Pavel Cisar

unread,
Jul 4, 2022, 7:56:55 AM7/4/22
to firebird...@googlegroups.com
Hi,

Dne 03. 07. 22 v 16:10 Steve Naidamast napsal(a):
> Thank you, Mark, for your notes.
>
> What you describe does not appear to be beneficial for developers who want
> to package the Firebird Embedded Database Engine with their applications.

Why not?

> It leads to me to the question as why the Firebird-Driver author would make
> something so simple yet so complex by not using an easily modifiable
> configuration file.

As firebird-driver author, I can ensure you that it's definitely
possible to use "easily modifiable configuration file". However, there
is no predefined configuration file. Instead, you can read the driver
configuration yourself from any configuration file you want (uses
configparser for that).

For example, next code loads driver configuration from file placed in
user-specific conf. directory according to platform-specific directory
scheme.

from pathlib import Path
from firebird.base.config import get_directory_scheme, DirectoryScheme
from firebird.driver import driver_config

APP = 'my_app'

scheme: DirectoryScheme = get_directory_scheme(APP)
driver_conf_file: Path = self.scheme.user_config / 'firebird-driver.conf'

if driver_conf_file.is_file():
driver_config.read(driver_conf_file)
else:
# create config file with default values.
driver_conf_file.write_text(driver_config.get_config())

Loading configuration from CWD is even simpler:

from pathlib import Path
from firebird.driver import driver_config

driver_conf_file: Path = Path.cwd() / 'firebird-driver.conf'

if driver_conf_file.is_file():
driver_config.read(driver_conf_file)
else:
# create config file with default values.
driver_conf_file.write_text(driver_config.get_config())

> In any event, I have tried various uses of the fb_client_library
> configuration, none of which have worked so far...

Why?

You may easily set driver_config.fb_client_library.value to path where
Firebird embedded is installed with your app. Just check how to use
pathlib.Path for that. You may do so directly, or load the configuration
from file, or mix both methods (server+db config from file,
fb_client_library directly).

Just make sure that:

"Important

If you want to use specific Firebird client library, you must set the
value of DriverConfig.fb_client_library configuration option before your
application calls any from following functions: connect(),
create_database(), connect_server(), load_api() or get_api()."

regards
Pavel Cisar
IBPhoenix
Reply all
Reply to author
Forward
0 new messages