PostgreSQL到sqlite迁移问题

时间:2019-05-16 13:10:14

标签: sql django postgresql sqlite

我是Postgresql的新手。我有使用PostgreSQL的django项目。我想将现有的Postgresql数据库移至sqlite。为此,我尝试了本论坛中提到的不同方法,但是每种方法都给我带来各种错误。最后,一个名为potgresql-to-sqlite的工具对postgrql转储文件进行了一些小的更改。现在,我可以启动django webapp。但是在某个页面上会出现类似的错误,

  

TechItem'对象没有属性'_mi_selection_params_cache'

我有一个名为“ mi_selection_params”的列,但是在我的数据库中没有诸如“ _mi_selection_params_cache”这样的列。

此错误是什么意思?我应该在哪里研究解决此问题的代码?

这是回溯,

    Traceback (most recent call last):
  File "E:\gir\python3.5\lib\site-packages\django\db\models\fields\related_descriptors.py", line 178, in __get__
    rel_obj = getattr(instance, self.cache_name)
AttributeError: 'TechItem' object has no attribute '_mi_selection_params_cache'

这是django related_discriptors.py中的代码

def __get__(self, instance, cls=None):
        """
        Get the related instance through the forward relation.

        With the example above, when getting ``child.parent``:

        - ``self`` is the descriptor managing the ``parent`` attribute
        - ``instance`` is the ``child`` instance
        - ``cls`` is the ``Child`` class (we don't need it)
        """
        if instance is None:
            return self

        # The related instance is loaded from the database and then cached in
        # the attribute defined in self.cache_name. It can also be pre-cached
        # by the reverse accessor (ReverseOneToOneDescriptor).
        try:
            rel_obj = getattr(instance, self.cache_name)
        except AttributeError:
            val = self.field.get_local_related_value(instance)
            if None in val:
                rel_obj = None
            else:
                rel_obj = self.get_object(instance)
                # If this is a one-to-one relation, set the reverse accessor
                # cache on the related object to the current instance to avoid
                # an extra SQL query if it's accessed later on.
                if not self.field.remote_field.multiple:
                    setattr(rel_obj, self.field.remote_field.get_cache_name(), instance)
            setattr(instance, self.cache_name, rel_obj)

        if rel_obj is None and not self.field.null:
            raise self.RelatedObjectDoesNotExist(
                "%s has no %s." % (self.field.model.__name__, self.field.name)
            )
        else:
            return rel_obj

0 个答案:

没有答案