Home > front end >  Python Firebird WinError 193 connection error
Python Firebird WinError 193 connection error

Time:11-05

import fdb

def main():
    con = fdb.connect(dsn='C:\AKINSOFT\Wolvox8\Database_FB\SIRKET.FDB', user='sysdba', password='masterkey')

if __name__ == '__main__':
    main()

I wrote a simple code for connecting a Firebird database with Python and fdb. When I run this, I get an winerror 193

Traceback (most recent call last):
  File "C:\Users\grand\PycharmProjects\DatabaseTest\main.py", line 9, in <module>
    main()
  File "C:\Users\grand\PycharmProjects\DatabaseTest\main.py", line 5, in main
    con = fdb.connect(dsn='C:\AKINSOFT\Wolvox8\Database_FB\SIRKET.FDB', user='sysdba', password='masterkey')
  File "C:\Users\grand\PycharmProjects\DatabaseTest\venv\lib\site-packages\fdb\fbcore.py", line 803, in connect
    load_api(fb_library_name)
  File "C:\Users\grand\PycharmProjects\DatabaseTest\venv\lib\site-packages\fdb\fbcore.py", line 231, in load_api
    setattr(sys.modules[__name__], 'api', ibase.fbclient_API(fb_library_name))
  File "C:\Users\grand\PycharmProjects\DatabaseTest\venv\lib\site-packages\fdb\ibase.py", line 1396, in __init__
    fb_library = WinDLL(fb_library_name)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 374, in __init__
    self._handle = _dlopen(self._name, mode)
  OSError: [WinError 193] %1 geçerli bir Win32 uygulaması değil 

CodePudding user response:

The English error is "[WinError 193] %1 is not a valid Win32 application", and it means you're trying to load a 32-bit DLL in a 64-bit process (or a 64-bit DLL in a 32-bit process). This means that you don't have a valid fbclient.dll on the PATH that matches the bitness of your Python process, but do have one of the wrong bitness.

So, find out if you're using a 32-bit or 64-bit Python (likely 64-bit these days), and use a Firebird installer of the appropriate bitness to install the client library.

If you don't have or don't want fbclient.dll on the PATH, you can also use fdb.load_api(..) or the fb_library_name connection property to specify the path to a fbclient.dll of the appropriate bitness.

As an aside, fdb has been superseded by the firebird-driver library.

  • Related