Giter Club home page Giter Club logo

Comments (6)

rivf avatar rivf commented on July 19, 2024

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.

from django-firebird.

maxirobaina avatar maxirobaina commented on July 19, 2024

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)

from django-firebird.

rivf avatar rivf commented on July 19, 2024
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.

from django-firebird.

rivf avatar rivf commented on July 19, 2024

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.

from django-firebird.

maxirobaina avatar maxirobaina commented on July 19, 2024

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.

from django-firebird.

rivf avatar rivf commented on July 19, 2024

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.

from django-firebird.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.