jacobalberty / firebird-docker

Firebird Dockerfile
130 stars 96 forks source link

Unable to connect from Python? #5

Closed gamesbook closed 8 years ago

gamesbook commented 8 years ago

From host machine:

docker ps

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
af9b03a78fcd        jb/firebird:2.5     "/usr/local/firebird/"   5 hours ago         Up 5 hours          0.0.0.0:3050->3050/tcp   firebird

From Inside the Docker:

cd /usr/local/firebird/bin
./isql        
SQL> CONNECT "/databases/STAR.DB" user sysdba password masterkey;
Commit current transaction (y/n)?y
Committing.
Database:  "/databases/STAR.DB", User: sysdba

and the usual SQL statements work in terms of access to tables, data etc.

From a Python terminal:

import fdb
con = fdb.connect(host='127.0.0.1:3050', database='/databases/STAR.DB', 
                  user='sysdba', password='masterkey')

Results in error:

Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/home/derek/.venvs/firebird/local/lib/python2.7/site-packages/fdb/fbcore.py", line 728, in connect
    "Error while connecting to database:")
fdb.fbcore.DatabaseError: ('Error while connecting to database:\n- SQLCODE: -904\n- unavailable database', -904, 335544375)

I have tried host='localhost:3050', and also using my machine's IP address. I have also tried dropping the '/databases/' prefix from the database name; but always the same error.

EDIT

I also installed FlameRobin (http://www.flamerobin.org/) and was able to connect to the DB server but, again, not to the database (trying different paths), so I don't think this is a Python problem. I also tried changing ownership of the DB.

gamesbook commented 8 years ago

Did not RTFM: http://firebirdsql.org/file/documentation/drivers_documentation/python/fdb/usage-guide.html#using-connect

Should be: con = fdb.connect(host='127.0.0.1', port='3050', database='/databases/STAR.DB', user='sysdba', password='masterkey')