1

I've been writing a small Python application that opens a Firebird database.
To achieve this goal I'm using Firebird embedded 2.5.7.27050, 64 bit.

Although, whenever I try to connect to the DB file with Python, I get the following error:

Traceback (most recent call last):
  File "C:\Matteo\CMakeR\initApp.py", line 36, in <module>
    connection = connectToDB(path)
  File "C:\Matteo\CMakeR\initApp.py", line 10, in connectToDB
    charset='WIN1252'
  File "C:\Program Files\Python36\lib\site-packages\fdb\fbcore.py", line 682, in connect
    load_api(fb_library_name)
  File "C:\Program Files\Python36\lib\site-packages\fdb\fbcore.py", line 181, in load_api
    setattr(sys.modules[__name__],'api',fbclient_API(fb_library_name))
  File "C:\Program Files\Python36\lib\site-packages\fdb\ibase.py", line 1398, in __init__
    raise Exception("The location of Firebird Client Library could not be determined.")
Exception: The location of Firebird Client Library could not be determined.
>>> 

It seems that the FB Client is not installed properly.
However I followed very carefully the installation guide inside the doc folder.
Here's my app folder:

04/01/2018  15:11    <DIR>          .
04/01/2018  15:11    <DIR>          ..
04/01/2018  14:57               133 aliases.conf
03/01/2018  14:20                 0 CMakeR.conf
02/01/2018  13:40             2.480 DB in chiaro.odb
04/01/2018  14:57    <DIR>          doc
30/12/2017  17:32               191 editXLS.py
30/12/2017  17:24            23.032 Export.xlsx
04/01/2018  14:57         5.664.256 fbclient.dll
04/01/2018  14:57         5.664.256 fbembed.dll
04/01/2018  14:46         5.199.849 Firebird-2.5.7.27050-0_x64_embed.zip
04/01/2018  14:57            27.661 firebird.conf
04/01/2018  14:57           149.440 firebird.msg
04/01/2018  14:57         5.664.256 gds32.dll
04/01/2018  14:57             8.192 ib_util.dll
04/01/2018  14:57         1.558.016 icudt30.dll
04/01/2018  14:57           575.488 icuin30.dll
04/01/2018  14:57           935.936 icuuc30.dll
04/01/2018  14:57            26.023 IDPLicense.txt
04/01/2018  15:09             1.583 initApp.py
04/01/2018  14:57    <DIR>          intl
04/01/2018  14:57            24.301 IPLicense.txt
04/01/2018  14:57               524 Microsoft.VC80.CRT.manifest
30/12/2017  17:24            28.625 Modulo CMR.xlsx
04/01/2018  14:57         1.097.728 msvcp80.dll
04/01/2018  14:57           822.784 msvcr80.dll
04/01/2018  14:57             2.333 Readme.txt
02/01/2018  13:40        50.790.400 testArchive.eft
04/01/2018  14:57    <DIR>          udf
  • 1
    Things don't magically stop working, so what changed? – Mark Rotteveel Dec 30 '17 at 16:14
  • @MarkRotteveel I honestly don't know and I feel very embaressed because of this. I was hoping that someone could tell me how to configure Firebird embedded. I did read the docs and I did everything they mentioned. –  Jan 02 '18 at 14:52
  • First try to trace your steps back to when it worked, and otherwise I suggest you post your question to the firebird-python mailing list. I don't regularly use Firebird embedded nor Python, so I don't know all ins and outs. – Mark Rotteveel Jan 02 '18 at 15:10
  • @MarkRotteveel thank you for the comment. I'll try writing to the mailing list, I'll let you know. Thanks again. –  Jan 02 '18 at 18:03
  • One easiest idea is that he changed Python implementation and now runs his script with 32-bits Python engine, rather than 64-bits which runned the script before. And if he maybe uses something like Jython making such a switch would be as easy as setting different JVM as default one :-D – Arioch 'The Jan 08 '18 at 11:49
  • One very common suggestion, like ABC, is just "run SysInternals Process Monitor; tune it to filter file I/o events from your python app, and then catch that very moment of failed process (here: DB connection attempt) into logs. Then check which files (DLLs) and where it tries to look for". Usually this gives a clue what kind of settings need fixing. – Arioch 'The Jan 08 '18 at 11:53

2 Answers2

1

Thank you all for helping me solve this issue.
I finally found a solution thanks to Arioch 'The's suggestion.

Using Microsoft Process Monitor I was able to detect the folders where my app was looking for the client library. Then I noticed that they were the same folders specified in the PATH environment variable.
So I added the folder containing my Python file to the PATH variable and everything finally worked out.

  • 1
    two possible tricks to add: 1) modifying your Windows-global `PATH` to solve problem of one specific app seems quite an intrusive change. I think you could amend your application to change it's own app-local copy of `PATH` so it would both be not dependent upon global OS setting and would not affect other programs. 2) using Windows implementation details, you perhaps could load the needed DLL (should be fbEmbed.dll in your case, but dunno which one `fdb` actually tried) before connecting the database, and unload it after the connection - Win32 calls `LoadLibrary` and `FreeLibrary` to warm-up – Arioch 'The Apr 17 '19 at 08:51
0

I use embedded FB from .NET but still, I keep the firebird.msg file in the same folder as the app. And the intl & udf folders are not nested in FBE or some folder. I'd say that you set the folder to FBE and it's looking for the binaries there too. That also seems like what the layout is supposed to look like.

jl.
  • 752
  • 6
  • 19
  • 1
    Actually in the guide you posted, which is the same I read btw, there's a section where they discuss how to place FB files elsewhere. I did all the things there mentioned. –  Jan 02 '18 at 15:07