Opened 7 years ago
Closed 6 years ago
#29057 closed Cleanup/optimization (fixed)
contrib.postgres OID caching crashes when initializing a ConnectionHandler manually
Reported by: | Riccardo Di Virgilio | Owned by: | nobody |
---|---|---|---|
Component: | contrib.postgres | Version: | 2.0 |
Severity: | Normal | Keywords: | |
Cc: | Mariusz Felisiak | Triage Stage: | Accepted |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
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
Change History (5)
comment:1 by , 7 years ago
comment:2 by , 7 years ago
Cc: | added |
---|
comment:3 by , 7 years ago
Component: | Database layer (models, ORM) → contrib.postgres |
---|---|
Summary: | unable to retrive connection from ConnectionHandler in django 2.0 → contrib.postgres OID caching crashes when initializing a ConnectionHandler manually |
Triage Stage: | Unreviewed → Accepted |
Type: | Bug → Cleanup/optimization |
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?
comment:4 by , 7 years ago
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.
comment:5 by , 6 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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
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