Skip to content

database host configuration not work with version 2 #49

Closed
@Fred-si-c

Description

@Fred-si-c

Hello

We use firebird driver to connect to a remote database using driver_config.server_defaults

from firebird.driver import Connection, connect, driver_config

class Firebird:
    def __init__(
        self,
        host: str,
        db_name: str,
        user: str,
        password: str,
        port: int = 3050,
    ):
        driver_config.server_defaults.host.value = host  # at this point, I am sure that the value of host value is not localhost
        driver_config.server_defaults.port.value = str(port)
        driver_config.server_defaults.user.value = user
        driver_config.server_defaults.password.value = password
        self._db_name = db_name.upper()

    def gen_conn(self) -> Connection:
        return connect(self._db_name, charset='UTF8')

This code works with driver version 1.10.11, but since version 2.0.0, custom host is not used and driver try to connect to localhost instead of given host.

Traceback (most recent call last):
  File "/app/shared/client_processor.py", line 70, in process_client
    self._process_table(pg, fb, table_config)
  File "/app/shared/client_processor.py", line 97, in _process_table
    self._copy_fb_data_to_pg_table(pg, fb, table_config)
  File "/app/shared/client_processor.py", line 120, in _copy_fb_data_to_pg_table
    fb.get_data_from_script(table_config.fb_script),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/shared/firebird.py", line 30, in get_data_from_script
    with self.gen_conn() as conn:
         ^^^^^^^^^^^^^^^
  File "/app/shared/firebird.py", line 25, in gen_conn
    return connect(self._db_name, charset='UTF8')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/firebird/driver/core.py", line 2294, in connect
    return __make_connection(dsn, db_config.utf8filename.value, dpb.get_buffer(),
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/firebird/driver/core.py", line 2200, in __make_connection
    att = provider.attach_database(dsn, dpb, 'utf-8' if utf8filename else FS_ENCODING)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/firebird/driver/interfaces.py", line 1328, in attach_database
    self._check()
  File "/usr/local/lib/python3.12/site-packages/firebird/driver/interfaces.py", line 141, in _check
    raise self.__report(DatabaseError, self.status.get_errors())
firebird.driver.types.DatabaseError: Unable to complete network request to host "localhost".
-Failed to establish a connection.

I don’t know if we misuse the driver or if this is a bug in the driver. Can you help us to solve this issue ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions