If it is one time selection like storing in a user level settings, you can store the database to use in user model i.e. you have to customize default Usermodel in django and add one extra field to store the db type of the current user.
Then access the right db Author.objects.using(request.user.database).all() OR Author.objects.using('mysql').all() Author.objects.using('postgresql').all() You might have to use the database routers also. It depends on your detailed requirements. Official docs - https://docs.djangoproject.com/en/2.2/topics/db/multi-db/ Cheers! Regards, Chetan Ganji +91-900-483-4183 ganji.che...@gmail.com http://ryucoder.in On Fri, Jun 21, 2019 at 4:55 PM anilkumar sangu <sangu.anilku...@gmail.com> wrote: > Hello, > > I am working on Django > > I have a scenario like > I want to connect multiple databases. based on user selection. if user > selects MySql from front end my Api could able to connect MySql. if user > select postgreSql my api could able to connect to postgreSql based on user > selection dynamically. how to achieve this in Django Rest Api > > Thanks in advance > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/50a8fe84-0966-4b2c-bcf4-725f75a78609%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/50a8fe84-0966-4b2c-bcf4-725f75a78609%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAMKMUjuH_j_OGDpLQfQQZ8EqChRTXXvutNb%3DK%2BJEv76QJeQmFw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.