Monday, February 27, 2017

Re: Multiple Databases

But dylan, I have written that

Check1.objects.using('default').all()

gives me error.

On Mon, Feb 27, 2017 at 1:08 PM, Dylan Reinhold <dreinhold@gmail.com> wrote:
It is going to use the database named default.
Checkout the doc on using mutiple DBs
https://docs.djangoproject.com/en/1.10/topics/db/multi-db/

Dylan


On Sun, Feb 26, 2017 at 11:17 PM, Luvpreet Singh <s.luvpreet33@gmail.com> wrote:
Hi everyone,

I am using 2 databases in my django app. One is default sqlite and second is postgre.

Now, I make a simple model named Check1 in my app, having only title attribute.

class Check1(models.Model):
      title = models.CharField(max_length=100)

Now, in my shell,

>> from check.models import Check1
>> a = Check1(title="first")
>> a.save()
>> Check1.objects.all()   --> this gives the queryset returning 'first'


My question is, in which database is it saved, means in my default db or my postgre db ? or in both ?

>> Check1.objects.using('default').all()    --> it gives me error
>> Check1.objects.using('newpostgre').all()  --> it gives me correct queryset.

How does I know or set that in which db it will be saved ?

--
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+unsubscribe@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/3c65b2a4-d409-44a6-8ea9-73aa15989eb2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/5sxIoy0mDcE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@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/CAHtg44BO8P5N-AfYvCjPnBn2p_GxRK9HQ_SRiUw8PWgWfKdtfA%40mail.gmail.com.

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+unsubscribe@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/CAL%2BrqijFBegKbKGmSAZgFEFpJWn75hVoCOYxPJi%3DLHFBrNs_FQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment