Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind Database Connection to certain classes #48

Open
paradoxon82 opened this issue Nov 6, 2015 · 2 comments
Open

Bind Database Connection to certain classes #48

paradoxon82 opened this issue Nov 6, 2015 · 2 comments

Comments

@paradoxon82
Copy link

Hello Jeremy,
we are using QDjango in our project for some time now and it worked well.
But now we added another database which stores a different type of data.
The problem now is that, as far as I can see, there is only a globally registered database connection.
We now have to change this connection in each method that does something with the database.
Is there a possibility to bind a connection to certain classes?
For example registering a property for the connection in the class that inherits the QDjangoModel class.

Best Regards,
Daniel

@jlaine
Copy link
Owner

jlaine commented Sep 22, 2016

Currently, no unfortunately there are no provisions for multi-db.

I'd be willing to review a DB routing proposal if it lines up with django's philosophy:

https://docs.djangoproject.com/en/1.10/topics/db/multi-db/

@paradoxon82
Copy link
Author

I added code to QDjango for testing that enables connecting a QDatabase object with a certain QDjangoModel when calling QDjango::registerModel(QDatabase)
When looking at the way Django does it, it seems a Router object would be registered with the model instead of directly giving the database.
Then QDjango could keep a map that keeps the Model->Router connection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants