0

我在 datajoint python 上0.13.1。在我的架构中的表上执行.alter()时,我收到以下错误消息:

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-43-f79406c4b690> in <module>
----> 1 MyTable.alter()

/opt/miniconda3/envs/analysis/lib/python3.6/site-packages/datajoint/table.py in alter(self, prompt, context)
    102             del frame
    103         old_definition = self.describe(context=context, printout=False)
--> 104         sql, external_stores = alter(self.definition, old_definition, context)
    105         if not sql:
    106             if prompt:

/opt/miniconda3/envs/analysis/lib/python3.6/site-packages/datajoint/user_tables.py in definition(self)
     75         """
     76         raise NotImplementedError(
---> 77             'Subclasses of Table must implement the property "definition"')
     78 
     79     @ClassProperty

NotImplementedError: Subclasses of Table must implement the property "definition"

我究竟做错了什么?

4

2 回答 2

3

说得通。目前,alter只能更改次要属性。我还不能修改外键、主键和索引。问题 #901 部分解释了这一点:https ://github.com/datajoint/datajoint-python/issues/901

当前的解决方法是使用 SQLALTER命令,您可以使用dj.conn().query(....). 如果您显示之前和之后的表定义,我将能够生成完整的ALTER命令。

于 2021-04-24T13:44:16.693 回答
1

问题之一是我没有直接加载模式代码。但是,然后错误消息更改为:

---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
<ipython-input-6-f79406c4b690> in <module>
----> 1 MyTable.alter()

/opt/miniconda3/envs/analysis/lib/python3.6/site-packages/datajoint/table.py in alter(self, prompt, context)
    102             del frame
    103         old_definition = self.describe(context=context, printout=False)
--> 104         sql, external_stores = alter(self.definition, old_definition, context)
    105         if not sql:
    106             if prompt:

/opt/miniconda3/envs/analysis/lib/python3.6/site-packages/datajoint/declare.py in alter(definition, old_definition, context)
    370         raise NotImplementedError('table.alter cannot alter foreign keys (yet).')
    371     if index_sql != index_sql_:
--> 372         raise NotImplementedError('table.alter cannot alter indexes (yet)')
    373     if attribute_sql != attribute_sql_:
    374         sql.extend(_make_attribute_alter(attribute_sql, attribute_sql_, primary_key))

NotImplementedError: table.alter cannot alter indexes (yet)
于 2021-04-24T11:25:15.410 回答