Can you really give a new database link with Django quickly?

I've a credit card applicatoin that utilizes multiple databases (django 1.2.1), even though running, it's permitted to produce new databases. I'd want to use this new database immediately (django.db.connections[db_alias]). Is it feasible without server restart? Using module reload in some places?

Appreciate your time and effort.

It's possible... although not suggested... You have access to the present connection handler...

Use something similar to this:

from django.db import connections
if not alias in connections.databases:
    connections.databases[alias] = connections.databases['default']  # Copy 'default'
    connections.databases[alias]['NAME'] = alias              

Make certain you don't make an effort to give a new alias towards the databases dictionary while there's ANY database activity around the current thread.

An problem you have to overcome, is this fact code will have to be placed somewhere were most commonly it is touched through the current thread prior to trying to gain access to the database. I personally use middleware to do this.