{"id":8153,"library":"fdb","title":"Firebird Database Driver (fdb)","description":"fdb is a Python driver for the Firebird relational database, implementing the Python DB-API 2.0 specification. While its PyPI summary refers to it as a \"Legacy Python driver for Firebird 2.5\", it continues to be actively maintained with recent releases (v2.0.4) fixing compatibility issues up to Python 3.13. It primarily interacts with Firebird via the native client library. The project has an active, though not rapid, release cadence, with updates addressing bugs and modern Python compatibility.","status":"active","version":"2.0.4","language":"en","source_language":"en","source_url":"https://github.com/FirebirdSQL/fdb","tags":["firebird","database","sql","dbapi","legacy"],"install":[{"cmd":"pip install fdb","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"The main module for accessing connection and error classes.","symbol":"fdb","correct":"import fdb"},{"note":"The base exception class for DB-API errors.","symbol":"fdb.Error","correct":"import fdb\ntry:\n    # ...\nexcept fdb.Error as e:\n    print(f\"Database error: {e}\")"},{"symbol":"fdb.connect","correct":"import fdb\nconn = fdb.connect(...)"}],"quickstart":{"code":"import fdb\nimport os\n\n# Ensure the Firebird client library (fbclient.dll/.so) is installed and discoverable.\n# Replace with your Firebird database path and credentials.\nDB_DSN = os.environ.get('FDB_DSN', 'localhost:/opt/firebird/data/test.fdb')\nDB_USER = os.environ.get('FDB_USER', 'sysdba')\nDB_PASSWORD = os.environ.get('FDB_PASSWORD', 'masterkey')\n\ntry:\n    # Establish a connection to the Firebird database\n    con = fdb.connect(dsn=DB_DSN,\n                      user=DB_USER, \n                      password=DB_PASSWORD)\n    print(\"Successfully connected to Firebird database.\")\n\n    # Create a cursor object\n    cur = con.cursor()\n\n    # Execute a SQL query\n    cur.execute(\"SELECT RDB$RELATION_NAME FROM RDB$RELATIONS WHERE RDB$SYSTEM_FLAG = 0\")\n\n    # Fetch and print results\n    print(\"\\nUser-defined tables:\")\n    for row in cur:\n        print(f\"- {row[0].strip()}\") # RDB$RELATION_NAME is CHAR, needs stripping\n\n    # Close the cursor and connection\n    cur.close()\n    con.close()\n    print(\"\\nConnection closed.\")\n\nexcept fdb.Error as e:\n    print(f\"Failed to connect or query Firebird database: {e}\")\n    print(\"Please ensure Firebird server is running, the client library is installed,\")\n    print(\"and the DSN/credentials are correct.\")\n","lang":"python","description":"This quickstart demonstrates how to establish a connection to a Firebird database, execute a simple query to list user-defined tables, and fetch the results using the `fdb` driver. It includes basic error handling and uses environment variables for sensitive connection details, which should be replaced with actual values or more secure methods in production."},"warnings":[{"fix":"Download and install the appropriate Firebird client package for your operating system and architecture from the official FirebirdSQL website. Ensure its installation directory is added to your system's dynamic linker search paths.","message":"The `fdb` library requires the native Firebird client library (e.g., `fbclient.dll` on Windows, `libfbclient.so` on Linux/macOS) to be installed and discoverable by your system's dynamic linker (e.g., in PATH on Windows, LD_LIBRARY_PATH on Linux, or standard system library paths). The Python package itself does not bundle this dependency.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Consult the FirebirdSQL documentation for specific server versions and cross-reference with `fdb` capabilities. For critical applications, consider thoroughly testing all database interactions or exploring alternative drivers if available for newer Firebird versions.","message":"While `fdb` is actively maintained for Python compatibility (e.g., up to Python 3.13), its PyPI description refers to it as a 'Legacy Python driver for Firebird 2.5'. Users connecting to modern Firebird server versions (4.0, 5.0 and above) might encounter specific features or data types that are not fully supported or require workarounds. Always test thoroughly with your specific Firebird server version.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Double-check your database path, especially on Linux/Unix systems. Ensure `user` and `password` match exactly. For the DSN, `hostname:/path/to/database.fdb` is a common format; ensure the path is correct and accessible by the Firebird server.","message":"Firebird database names (DSN) and connection parameters are case-sensitive on some operating systems and depend on how the database was created. Incorrect case or path separators can lead to connection failures.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Install the correct Firebird client library for your OS/architecture. Ensure the library's directory is in your system's PATH (Windows) or LD_LIBRARY_PATH (Linux) or other relevant linker paths.","cause":"The Firebird client library is either not installed, not discoverable in the system's library paths, or is an incompatible version for your Firebird server.","error":"fdb.fbcore.FdbError: ('Error loading plugin FBA_AUTH', -902, 335544451)"},{"fix":"Verify that the Firebird server service is running. Check your firewall settings. Confirm the database file path in your DSN is correct and the file exists on the server machine.","cause":"The Firebird server is not running, is inaccessible (e.g., firewall blocking port 3050), or the database file specified in the DSN does not exist or is corrupted.","error":"fdb.fbcore.FdbError: database connection is not available"},{"fix":"Always provide valid `user` and `password` arguments to `fdb.connect()`. Common defaults are `user='sysdba', password='masterkey'` (case-sensitive) for initial setup, but these should be changed for production.","cause":"The `user` or `password` parameters were omitted or incorrect in the `fdb.connect()` call.","error":"fdb.fbcore.FdbError: no user name for connection"}]}