Skip to content

firebird driver - firebird.driver.types.DatabaseError: connection shutdown #72

@Alek5andr

Description

@Alek5andr

Hi!

I coped with the following issue:

Exception ignored in: <function Connection.__del__ at 0x000002CEDE2D5630>
Traceback (most recent call last):
  File "C:\Users\Windows\AppData\Local\Programs\Python\Python310\lib\site-packages\firebird\driver\core.py", line 1662, in __del__
    self._att.detach()
  File "C:\Users\Windows\AppData\Local\Programs\Python\Python310\lib\site-packages\firebird\driver\interfaces.py", line 1181, in detach
    self._check()
  File "C:\Users\Windows\AppData\Local\Programs\Python\Python310\lib\site-packages\firebird\driver\interfaces.py", line 113, in _check
    raise self.__report(DatabaseError, self.status.get_errors())
firebird.driver.types.DatabaseError: connection shutdown

in version 2.1 of sqlalchemy-firebird. However, I've found that the similar issue with "fdb" driver was fixed in #38. Still it persists with "firebird" driver.

The following code can help to reproduce the error

import json
from sqlalchemy import create_engine
from sqlalchemy.orm import Session
from sqlalchemy import URL
from sqlalchemy import text
from sqlalchemy.orm import sessionmaker


def main():
    fb_cursor = firebird_session()
    fetch_operations_from_fb(fb_cursor)
    fb_cursor.close()


def firebird_session() -> Session:
    with open('../config/database/firebird.json') as f:
        j = json.loads(f.read())

    url_object = URL.create(
        "firebird+firebird",
        username=j["user"],
        password=j["password"],
        host=j["host"],
        port=j["port"],
        database=j["database"],
        query={"charset": "UTF8",
               "fb_client_library": "../clients/firebird3/fbclient.dll"}
    )

    engine = create_engine(url_object, echo=True)
    session = sessionmaker(bind=engine)
    return session()


def fetch_operations_from_fb(session: Session):
    count_query = text('SELECT COUNT(1) FROM USERS;')
    amount_of_users = session.execute(count_query).fetchone()[0]
    print(amount_of_users)


main()

No clue what does cause the error. But 1 thing I've noticed, that making NO query and closing the connection right after its opening does not produce the error.

Any ideas where to dig next or how to overcome the issue are welcomed.
Thanks!

P.S.
Tools

  • Windows 10
  • Python 3.10
  • Firebird 3
  • SQLAlchemy 2.0.36
  • sqlalchemy-firebird 2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions