{{{
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.
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>
* cc: felixxm (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/29057#comment:2>
* 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>
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>
* 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>