Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS — SQLCODE: -904\n- invalid database handle (no active connection) #118

Open
devnoname120 opened this issue Dec 6, 2024 · 1 comment

Comments

@devnoname120
Copy link

devnoname120 commented Dec 6, 2024

Crossposted from #103 (comment)

I use macOS and both the Firebird server and Python script run locally.

My configuration:

  • MacBook Pro with Apple M2 Max (arm64 / Apple Silicon)
  • macOS: 14.7.1 (Sonoma)
  • Firebird: 5.0.1.1469 (arm64)
  • Python: 3.12.8
    • fdb: 2.0.2

However when I attempt to use fdb in order to connect to a Firebird database through a local server it doesn't work. I wrote the following code:

import fdb

conn = fdb.connect(
    host='localhost',
    port=3050,
    database='/Users/paul/STTDB3.FDB5',
    user='sysdba',
    password='masterkey'
)

cursor = conn.cursor()
cursor.execute("SELECT COUNT(*) FROM PLAYLIST")
print(cursor.fetchone()[0])

And when I attempt to run it then an error happens on the cursor.execute() line:

❯ python3 script.py

Error: ('Error while starting transaction:\n- SQLCODE: -904\n- invalid database handle (no active connection)', -904, 335544324)

I confirm that I can indeed access the database via isql without any issues:

❯ isql -u sysdba -p masterkey inet4://localhost:3050//Users/paul/STTDB3.FDB5 
Database: inet4://localhost:3050//Users/paul/STTDB3.FDB5, User: SYSDBA

SQL> SELECT COUNT(*) FROM CHANNELS;

                COUNT 
===================== 
                    5 

And interestingly, if I switch to the (unfortunately 10 times slower) firebirdsql library then it also works without issues so it really seems to be an issue with fdb:

- import fdb
+ import firebirdsql as fdb

Gives the following when run:

❯ python3 script.py

5
@devnoname120 devnoname120 changed the title macOS — SQLCODE: -904\n- invalid database handle (no active connection) macOS — SQLCODE: -904\n- invalid database handle (no active connection) Dec 6, 2024
@pcisar
Copy link
Contributor

pcisar commented Dec 6, 2024

FDB is a legacy driver, not actively maintained. Did you try the firebird-driver, which is the official driver for Firebird 3+?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants