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

django-firebird 1.7 not working with firebird 2.5.1 and django 1.7 for non-default firebird port. #62

Closed
rivf opened this issue Apr 20, 2016 · 6 comments
Assignees
Labels
Milestone

Comments

@rivf
Copy link

rivf commented Apr 20, 2016

Hi!
I'm using the following setup (all installed with pip install):
Django (1.7.11)
django-firebird (1.7)
fdb (1.6)

I connect to firebird database with gui razorsql and I connect successfully with this line:
jdbc:firebirdsql://test.testdomain.com:18006/DBtest (I changed a bit domain and port, and of course there are also user/password)

I have clean django project created by django 1.7.11 with this modification:

DATABASES = {
    'default': {
        'ENGINE' : 'firebird',
        'NAME' : 'DBtest', # Path to database or db alias
        'USER' : 'user',           # Your db user
        'PASSWORD' : '*****',    # db user password
        'HOST' : 'test.testdomain.com',        # Your host machine
        'PORT' : '18006',             # If is empty, use default 3050
    }
}

(of course with right user and password)

When I launch server (python manage.py runserver) nothing happens.

python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).

when I launch it with deafult sqlite generated settings:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}

default launching happens:

python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).

You have unapplied migrations; your app may not work properly until they are applied.
Run 'python manage.py migrate' to apply them.

April 20, 2016 - 13:55:50
Django version 1.7.11, using settings 'demofb.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

So smth is wrong with firebird database setup. But what? Maybe I should use different combination of versions?

@rivf
Copy link
Author

rivf commented Apr 20, 2016

When I use firebird database as second database (first is sqlite) and connect with this code:

from django.db import connections
cursor = connections['firebird_db'].cursor()

I get:

DatabaseError at /test/
('Error while connecting to database:\n- SQLCODE: -902\n- Unable to complete network request to host "test.testdomain.com".\n- Failed to establish a connection.', -902, 335544721)

I also get the same when I use firebird database as default database and execute
python manage.py migrate

Then I tried to use fdb alone (same fdb install on same virtualenv and inside same django view):

con = fdb.connect(dsn='test.testdomain.com/18006:DBtest', user='user', password='*******')
cur = con.cursor()
cur.execute("SELECT * FROM TESTTABLE")

And it worked, I connected to database successfully. So the question is - why django-firebird can't connect? It uses the same fdb driver.

@maxirobaina
Copy link
Owner

Hi rivf,
I can't reproduce this error into my environment. All I can see quickly is you're not using the default port.

-902 335544721 is a network_error

Please try:
con = fdb.connect(dsn='test.testdomain.com:DBtest', user='user', password='*******', port=18006)

@rivf
Copy link
Author

rivf commented Apr 20, 2016

Please try:
con = fdb.connect(dsn='test.testdomain.com:DBtest', user='user', password='*******', port=18006)

not working, but exactly the same error (last time it was produced not by fdb, but by django-firebird):

DatabaseError at /test/
('Error while connecting to database:\n- SQLCODE: -902\n- Unable to complete network request to host "test.testdomain.com".\n- Failed to establish a connection.', -902, 335544721)

but this works fine:
con = fdb.connect(dsn='test.testdomain.com/18006:DBtest', user='user', password='*******')

Any ideas? Btw, I can't change port to default in this particular case.

@rivf
Copy link
Author

rivf commented Apr 20, 2016

I've solved the problem.

DATABASES = {
    'default': {
        'ENGINE' : 'firebird',
        'NAME' : 'DBtest', # Path to database or db alias
        'USER' : 'user',           # Your db user
        'PASSWORD' : '*****',    # db user password
        'HOST' : 'test.testdomain.com',        # Your host machine
        'PORT' : '18006',             # If is empty, use default 3050
    }
}

Above code is not working

DATABASES = {
    'default': {
        'ENGINE' : 'firebird',
        'NAME' : 'DBtest', # Path to database or db alias
        'USER' : 'user',           # Your db user
        'PASSWORD' : '*****',    # db user password
        'HOST' : 'test.testdomain.com/18006',        # Your host machine
        #'PORT' : '18006',             # If is empty, use default 3050
    }
}

Works!

So you should fix your manual, add something about host/port setting.

@maxirobaina
Copy link
Owner

maxirobaina commented Apr 20, 2016

With a settings like this:

DATABASES = {
    'default': {
        'ENGINE' : 'firebird',
        'NAME' : 'DBtest', # Path to database or db alias
        'USER' : 'SYSDBA',           # Your db user
        'PASSWORD' : 'masterkey',    # db user password
        'HOST' : '127.0.0.1',        # Your host machine
        'PORT' : '3050',             # If is empty, use default 3050
    }
}

Try this from a shell (./manage.py shell)

from django.db import connection

connection.get_connection_params()

It must returns, for example something like
{'dsn': '127.0.0.1:DBtest', 'charset': 'ISO8859_1', 'user': 'SYSDBA', 'password': 'masterkey', 'port': '3050'}

Now,

import fdb
from django.db import connection

params = connection.get_connection_params()
conn = fdb.connect(**params)

It should work too.

@rivf
Copy link
Author

rivf commented May 18, 2016

With your example database code

from django.db import connection

connection.get_connection_params()

returns:
{'dsn': '127.0.0.1:DBtest', 'password': 'masterkey', 'charset': 'UTF8', 'port': '3050', 'user': 'SYSDBA'}

DATABASES = {
    'default': {
        'ENGINE' : 'firebird',
        'NAME' : 'DBtest', # Path to database or db alias
        'USER' : 'user',           # Your db user
        'PASSWORD' : '*****',    # db user password
        'HOST' : 'test.testdomain.com/18006',        # Your host machine
        #'PORT' : '18006',             # If is empty, use default 3050
    }
}

returns:
{'dsn': 'test.testdomain.com:DBtest/18006', 'password': '*****', 'charset': 'UTF8', 'user': 'user'}

And it works for this non default port.

What you suggest is not working. Please try to use your backend with non-default port. I think it's bug.

So again: when I use
'HOST' : 'test.testdomain.com,
and
'PORT' : '18006',
It can't connect to the database.

'HOST' : 'test.testdomain.com/18006',
With this host line and port line commented or deleted connects successfully.

Also I need to add that the database is 2.5.1, not 2.5.2, but I don't think it's important.

@rivf rivf changed the title django-firebird 1.7 not working with firebird 2.5.2 and django 1.7 django-firebird 1.7 not working with firebird 2.5.1 and django 1.7 for non-default firebird port. May 18, 2016
@maxirobaina maxirobaina added the bug label Jul 1, 2016
@maxirobaina maxirobaina self-assigned this Jul 1, 2016
@maxirobaina maxirobaina added this to the 1.7.0 milestone Jul 1, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants