1

django Web ページの公式の手順に従っても、このエラーが発生し続けます。

return Database.Cursor.execute(self, query, params)

django.db.utils.OperationalError: データベースがロックされています

私の問題は、古い列から新しい列にデータを移行しようとしていることです:

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations

def move_names(apps, schema_editor):
    Comment = apps.get_model("article", "Comment")
    for comment in Comment.objects.all():
        try:
            comment.first_name, comment.second_name = comment.name.split(" ")
        except:
            comment.first_name, comment.second_name = comment.name, ""
        comment.save()

def backwards(apps, schema_editor):
    for comment in Comment.objects.all():
        comment.name = ""
        comment.save()

class Migration(migrations.Migration):

    dependencies = [
        ('article', '0007_auto_20141109_2005'),
    ]

    operations = [
        migrations.RunPython(move_names),
        #migrations.RunPython(backwards),
    ]
4

0 に答える 0