-
Notifications
You must be signed in to change notification settings - Fork 48
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
Multiple DB Connections with DB Alias Does import to correct DB #143
Comments
Interesting. I thought I had unittests that covered this use case. Your report suggests they are inaccurate. Do the tests pass for you? |
I didn't run any tests. Sorry, I don't know how to run the tests. Would be happy to know the steps. |
I went through the code Strange! But below is working: MyModel.objects.from_csv('/csv/file/import_path.csv', using='basf') Just an FYI, |
Hmm. It's been long enough since I wrote that code that I've forgotten the history. I'm glad we found you a workaround for now. I'll give it a look when I find some time. If you have a PR you'd like to suggest, I'd welcome it. |
Currently, I do not have any PR. The code changes I made here didn't work so I've to think of a different way to achieve the import by generic implementation of |
For Django projects having multiple DB connections something like this:
CSV import (
from_csv
) doesn't seem to be working. It looks like no matter what ever DB alias I give, it always refer todefault
DB alias.eg:
MyModel.objects.using('basf').from_csv('/csv/file/import_path.csv')
- Imports the data todefault
DB connection instead ofbasf
.MyModel.objects.using('NotExisted').from_csv('/csv/file/import_path.csv')
- Still worked and imported todefault
DB Alias instead of throwing error:DB connection doesn't exist.
Though, exporting (
to_csv
) functionality worked perfectly with DB aliases:MyModel.objects.using('basf').to_csv('/csv/file/export_path.csv')
-- Exportedbasf
DB perfectly.MyModel.objects.using('NotExisted').to_csv('/csv/file/export_path.csv')
- Raiseddjango.utils.connection.ConnectionDoesNotExist
which was expected.Below is my specs:
Any quick fix to make CSV import for multiple DB aliases?
I tried something from my end but still didn't work:
The text was updated successfully, but these errors were encountered: