Hi,
You should select the database you want to use:
Calls.objects.using('calls').all()
See
https://docs.djangoproject.com/en/1.9/topics/db/multi-db/#manually-selecting-a-database
On Thursday, 9 June 2016 14:13:22 UTC+2, Galil wrote:
>
> Hello,
>
> I am using two databses for my Django app and one of them is an existing
> MySQL database:
>
> DATABASES = {
> 'default': {
> 'ENGINE': 'django.db.backends.sqlite3',
> 'NAME': os.path.join(BASE_DIR, 'users.sqlite3'),
> },
> 'calls': {
> 'ENGINE': 'django.db.backends.mysql',
> 'NAME': 'portal2',
> 'USER': 'cdraccess',
> 'PASSWORD': '******',
> 'HOST': '[MY_HOST]',
> },
>
> }
>
>
> I used inspectdb to create the models for the call and they look like:
>
> class Calls(models.Model):
> callid = models.AutoField(db_column='CallID', primary_key=True) # Field
> name made lowercase.
> conferencename = models.CharField(db_column='ConferenceName', max_length=
> 200) # Field name made lowercase.
> jointime = models.DateTimeField(db_column='JoinTime') # Field name made
> lowercase.
> leavetime = models.DateTimeField(db_column='LeaveTime', blank=True, null=
> True) # Field name made lowercase.
>
> class Meta:
> managed = True
> db_table = 'ConferenceCall2'
>
>
> I called makemigrations and then migrate and everything looks fine.
>
> However, when I run a query like Calls.objects.all() the result is: [].
>
> Or when I tried Calls..objects.count() the result was: 0. The MySQL database
> is not empty, but apparently Django ORM believes that it is.
>
> Am I missing something?
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
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/b283f4f1-b9ce-4c4e-84bc-b1d2be376931%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.