Upgrading from 1.11 to 2.0: "sqlite3.OperationalError: no such table"

39 views
Skip to first unread message

Michael Gauland

unread,
May 3, 2018, 8:33:50 PM5/3/18
to Django users
I've got a project that's been developed using django 1.11. I've tried upgrading to 2.0, but now I'm getting an error I haven't been able to track down.

My database engine is sqlite3. I have three database files:
  - db.sqlite3 is the default. This is the only one that django manages, and the only one that is writable.
  - components.sqlite3 contains a library of engineering component data.
  - slat_constants.sqlite3 contains constants used by the project. In particular, the 'slat_locations' table holds information about sites in NZ.

I have a Model that exposes the location data:
    class Location(models.Model):
        location = models.CharField(max_length=128)
        z = models.FloatField()
        min_distance = models.FloatField(null = True)
        max_disstance = models.FloatField(null = True)

        class Meta:
            managed = False
            db_table = 'slat_location'

and another that uses it:
    class NZ_Standard_Curve(models.Model):
        SOIL_CLASS_A = 'A'
        SOIL_CLASS_B = 'B'
        SOIL_CLASS_C = 'C'
        SOIL_CLASS_D = 'D'
        SOIL_CLASS_E = 'E'
        SOIL_CLASS_CHOICES = (
            (SOIL_CLASS_A, 'A'),
            (SOIL_CLASS_B, 'B'),
            (SOIL_CLASS_C, 'C'),
            (SOIL_CLASS_D, 'D'),
            (SOIL_CLASS_E, 'E')
        )

        soil_class = models.CharField(max_length=1,
                                      choices=SOIL_CLASS_CHOICES,
                                      default=SOIL_CLASS_A)
        period = models.FloatField(default=1.5)
        location = models.ForeignKey(Location, on_delete=PROTECT, null=False)

...and a test script that creates an NZ_Standard_Curve, and tries to save it:

        location = Location.objects.get(location='Christchurch')
        curve = NZ_Standard_Curve(location=location,
                                   soil_class='C',
                                   period=1.5)
        curve.save()

If I don't try to save the curve, the test passes. The save() call fails with:

    sqlite3.OperationalError: no such table: main.slat_location

Again, this all works with django 1.11.13. I've tried creating a fresh database, and making new migrations, but that hasn't helped.

I've wondered if the leading 'main.' in the table name is a clue, but that hasn't led me anywhere yet.

Any suggestions?

Kind Regards,
Michael Gauland

Michael Gauland

unread,
May 6, 2018, 11:38:23 PM5/6/18
to Django users
Just in case anyone else runs into this, I fixed it by specifying db_contraint=False for foreign keys which cross databases.

Informatico Neurodesarrollo

unread,
May 8, 2018, 3:00:01 PM5/8/18
to django...@googlegroups.com
Check 1.11 to 2.0 upgrade.
You already checked the project configuration and make migrations ?, it could be changed with the upgrade!!!
I will hope help you.

PD I'm a beginner in Django.

El 06/05/18 a las 23:38, Michael Gauland escribió:
Just in case anyone else runs into this, I fixed it by specifying db_contraint=False for foreign keys which cross databases.
--
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...@googlegroups.com.
To post to this group, send email to django...@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/aaca2372-f0f3-4e60-98cc-b7f906867606%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 

Jesús Reyes Piedra
Admin Red Neurodesarrollo,Cárdenas
La caja decía:"Requiere windows 95 o superior"...
Entonces instalé LINUX. 
Reply all
Reply to author
Forward
0 new messages