首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >调用.alter()时的NotImplementedError (0.13.1)

调用.alter()时的NotImplementedError (0.13.1)
EN

Stack Overflow用户
提问于 2021-04-24 19:23:00
回答 2查看 19关注 0票数 0

我使用的是数据联合python 0.13.1。当在我的模式中的表上执行.alter()时,我得到了以下错误消息:

代码语言:javascript
复制
---------------------------------------------------------------------------
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"

我做错了什么?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2021-04-24 21:44:17

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

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

票数 0
EN

Stack Overflow用户

发布于 2021-04-24 19:25:15

其中一个问题是我没有直接加载模式代码。但是,错误消息将更改为:

代码语言:javascript
复制
---------------------------------------------------------------------------
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)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67242242

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档