微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

调用 .alter() (0.13.1) 时出现 NotImplementedError

如何解决调用 .alter() (0.13.1) 时出现 NotImplementedError

我正在使用 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"

我做错了什么?

解决方法

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

---------------------------------------------------------------------------
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,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)
,

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

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?