[Django] #29057: unable to retrive connection from ConnectionHandler in django 2.0

22 views
Skip to first unread message

Django

unread,
Jan 25, 2018, 6:23:29 AM1/25/18
to django-...@googlegroups.com
#29057: unable to retrive connection from ConnectionHandler in django 2.0
-------------------------------------+-------------------------------------
Reporter: Riccardo | Owner: nobody
Di Virgilio |
Type: Bug | Status: new
Component: Database | Version: 2.0
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
please note that this works on django 1.10


{{{
c = ConnectionHandler( {'temp': {'NAME': 'template1', 'ENGINE':
'django.db.backends.postgresql', 'USER': 'rdv', 'HOST': 'localhost',
'PORT': '5432', 'PASSWORD': '', 'OPTIONS': {}, 'READONLY': False,
'BACKUP': False, 'RESTORE': 'release', 'RESTORE_AUTO': True,
'ATOMIC_REQUESTS': False, 'AUTOCOMMIT': True, 'CONN_MAX_AGE': 0,
'TIME_ZONE': None, 'TEST': {'CHARSET': None, 'COLLATION': None, 'NAME':
None, 'MIRROR': None}}, 'default': {'NAME': 'rotostampa_db', 'ENGINE':
'django.db.backends.postgresql', 'USER': 'rdv', 'HOST': 'localhost',
'PORT': '5432', 'PASSWORD': '', 'OPTIONS': {}, 'READONLY': False,
'BACKUP': False, 'RESTORE': 'release', 'RESTORE_AUTO': True,
'ATOMIC_REQUESTS': False, 'AUTOCOMMIT': True, 'CONN_MAX_AGE': 0,
'TIME_ZONE': None, 'TEST': {'CHARSET': None, 'COLLATION': None, 'NAME':
None, 'MIRROR': None}}})

c['temp'].cursor()
}}}


{{{
raise ConnectionDoesNotExist("The connection %s doesn't exist" % alias)
django.db.utils.ConnectionDoesNotExist: The connection temp doesn't exist
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29057>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Jan 25, 2018, 6:26:47 AM1/25/18
to django-...@googlegroups.com
#29057: unable to retrive connection from ConnectionHandler in django 2.0
-------------------------------------+-------------------------------------
Reporter: Riccardo Di | Owner: nobody

Virgilio |
Type: Bug | Status: new
Component: Database layer | Version: 2.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Riccardo Di Virgilio):

the problem is django.contrib.postgres.signals.
there is a registred signal that is trying to read from connections and
obviously it fails because "temp" is not registred


{{{
def get_hstore_oids(connection_alias):
"""Return hstore and hstore array OIDs."""
with connections[connection_alias]
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/29057#comment:1>

Django

unread,
Jan 25, 2018, 7:03:35 AM1/25/18
to django-...@googlegroups.com
#29057: unable to retrive connection from ConnectionHandler in django 2.0
-------------------------------------+-------------------------------------
Reporter: Riccardo Di | Owner: nobody

Virgilio |
Type: Bug | Status: new
Component: Database layer | Version: 2.0
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* cc: felixxm (added)


--
Ticket URL: <https://code.djangoproject.com/ticket/29057#comment:2>

Django

unread,
Jan 25, 2018, 1:06:00 PM1/25/18
to django-...@googlegroups.com
#29057: contrib.postgres OID caching crashes when initializing a ConnectionHandler
manually
--------------------------------------+------------------------------------
Reporter: Riccardo Di Virgilio | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.postgres | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tim Graham):

* type: Bug => Cleanup/optimization
* component: Database layer (models, ORM) => contrib.postgres
* stage: Unreviewed => Accepted


Comment:

While `ConnectionHandler` isn't a public API, I suppose we could change
the implementation of 86a18dc46aae3a4a6410e3f3d864fa0ec4e5b2cd to reallow
your use case. Would you like to provide a patch?

--
Ticket URL: <https://code.djangoproject.com/ticket/29057#comment:3>

Django

unread,
Jan 29, 2018, 2:56:55 AM1/29/18
to django-...@googlegroups.com
#29057: contrib.postgres OID caching crashes when initializing a ConnectionHandler
manually
--------------------------------------+------------------------------------
Reporter: Riccardo Di Virgilio | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: contrib.postgres | Version: 2.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Riccardo Di Virgilio):

I know is not a public API, but it was the only way for me to interact
with external databases without changing settings dynamically...

I normally offer to provide a patch, but for this bug I don't think I
should: I really don't know what this function that is connected to this
signal is doing...

sorry about that.

--
Ticket URL: <https://code.djangoproject.com/ticket/29057#comment:4>

Django

unread,
May 26, 2018, 10:26:16 AM5/26/18
to django-...@googlegroups.com
#29057: contrib.postgres OID caching crashes when initializing a ConnectionHandler
manually
--------------------------------------+------------------------------------
Reporter: Riccardo Di Virgilio | Owner: nobody
Type: Cleanup/optimization | Status: closed
Component: contrib.postgres | Version: 2.0
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Riccardo Di Virgilio):

* status: new => closed
* resolution: => fixed


Comment:

This bug seems to be fixed on latest master. I'm able to use the
connection handler to create a cursor and connect to a db.

thanks

--
Ticket URL: <https://code.djangoproject.com/ticket/29057#comment:5>

Reply all
Reply to author
Forward
0 new messages