将 SQLite 和 MySQL 与 Elixir 一起使用时,列不存在,但单独使用时不存在
在我的 Qgis 插件中,我目前必须使用两个数据库:SQLite 和 MySQL,为了与它们交互,我使用 Elixir 0.7.1 和 SqlAlchemy 0.7.4。当我只使用 SQLite 时,一切都很好,最近我添加了 MySQL 的模块,就我单独测试它们而言,它们工作得很好,但是当我把所有这些放在一起时,我从 qgis 得到了这个:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 164, in startPlugin
plugins[packageName] = package.classFactory(iface)
File "/home/giuseppe/.qgis/python/plugins/mmasgis/__init__.py", line 37, in classFactory
return mmasgis(iface)
File "/home/giuseppe/.qgis/python/plugins/mmasgis/mmasgis.py", line 84, in __init__
self.selectionList=Lista()
File "/home/giuseppe/.qgis/python/plugins/mmasgis/lista.py", line 7, in __init__
self.util=utility([],0)
File "/home/giuseppe/.qgis/python/plugins/mmasgis/utility.py", line 266, in __init__
initDB()
File "/home/giuseppe/.qgis/python/plugins/mmasgis/mysqlEntities.py", line 7, in initDB
setup_all()
File "/usr/lib/pymodules/python2.7/elixir/__init__.py", line 94, in setup_all
setup_entities(entities)
File "/usr/lib/pymodules/python2.7/elixir/entity.py", line 951, in setup_entities
method()
File "/usr/lib/pymodules/python2.7/elixir/entity.py", line 240, in setup_relkeys
self.call_builders('create_non_pk_cols')
File "/usr/lib/pymodules/python2.7/elixir/entity.py", line 481, in call_builders
getattr(builder, what)()
File "/usr/lib/pymodules/python2.7/elixir/fields.py", line 155, in create_non_pk_cols
self.create_col()
File "/usr/lib/pymodules/python2.7/elixir/fields.py", line 160, in create_col
self.add_table_column(self.column)
File "/usr/lib/pymodules/python2.7/elixir/properties.py", line 84, in add_table_column
self.entity._descriptor.add_column(column)
File "/usr/lib/pymodules/python2.7/elixir/entity.py", line 493, in add_column
(col.key, self.entity.__name__))
Exception: Column 'nome' already exist in 'Regione' !
Versione Python:
2.7.2+ (default, Oct 4 2011, 20:29:37)
[GCC 4.6.1]
Versione di QGIS:
1.9.90-Alpha Alpha, exported
Percorso Python: ['/usr/share/qgis/python', '/home/giuseppe/.qgis/python', '/home /giuseppe/.qgis/python/plugins', '/usr/share/qgis/python/plugins', '/usr/local/lib/python2.7/dist-packages/pyshp-1.1.4-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.7.4-py2.7-linux-i686.egg', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/Numeric', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/pymodules/python2.7/ubuntuone-dev-tools', '/usr/lib/pymodules/python2.7/libubuntuone', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client', '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', '/usr/lib/python2.7/dist-packages/ubuntuone-couch', '/usr/lib/python2.7/dist-packages/ubuntuone-file-storage-api', '/usr/lib/python2.7/dist-packages/ubuntuone-installer', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode', '/usr/share/qgis/python/plugins/fTools/tools', '/home/giuseppe/Documenti/doc/progetti/mmasgis/gianluca/ProgettoGIS', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/']
这是我的 SQLite 实体模块: < a href="http://pastebin.com/ya4q9En1" rel="nofollow">http://pastebin.com/ya4q9En1 这是 MySQL 的实体模块: http://pastebin.com/3NypygV4
你能帮我理解我的错误是?
In my plugin for Qgis I have to use two databases, SQLite and MySQL at the moment, for interfacing with them I use Elixir 0.7.1 and SqlAlchemy 0.7.4. When I only used SQLite, everything was fine, recently I added the module for MySQL, as far I test them separately, they work nicely, but when I put all together I got this from qgis :
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 164, in startPlugin
plugins[packageName] = package.classFactory(iface)
File "/home/giuseppe/.qgis/python/plugins/mmasgis/__init__.py", line 37, in classFactory
return mmasgis(iface)
File "/home/giuseppe/.qgis/python/plugins/mmasgis/mmasgis.py", line 84, in __init__
self.selectionList=Lista()
File "/home/giuseppe/.qgis/python/plugins/mmasgis/lista.py", line 7, in __init__
self.util=utility([],0)
File "/home/giuseppe/.qgis/python/plugins/mmasgis/utility.py", line 266, in __init__
initDB()
File "/home/giuseppe/.qgis/python/plugins/mmasgis/mysqlEntities.py", line 7, in initDB
setup_all()
File "/usr/lib/pymodules/python2.7/elixir/__init__.py", line 94, in setup_all
setup_entities(entities)
File "/usr/lib/pymodules/python2.7/elixir/entity.py", line 951, in setup_entities
method()
File "/usr/lib/pymodules/python2.7/elixir/entity.py", line 240, in setup_relkeys
self.call_builders('create_non_pk_cols')
File "/usr/lib/pymodules/python2.7/elixir/entity.py", line 481, in call_builders
getattr(builder, what)()
File "/usr/lib/pymodules/python2.7/elixir/fields.py", line 155, in create_non_pk_cols
self.create_col()
File "/usr/lib/pymodules/python2.7/elixir/fields.py", line 160, in create_col
self.add_table_column(self.column)
File "/usr/lib/pymodules/python2.7/elixir/properties.py", line 84, in add_table_column
self.entity._descriptor.add_column(column)
File "/usr/lib/pymodules/python2.7/elixir/entity.py", line 493, in add_column
(col.key, self.entity.__name__))
Exception: Column 'nome' already exist in 'Regione' !
Versione Python:
2.7.2+ (default, Oct 4 2011, 20:29:37)
[GCC 4.6.1]
Versione di QGIS:
1.9.90-Alpha Alpha, exported
Percorso Python: ['/usr/share/qgis/python', '/home/giuseppe/.qgis/python', '/home /giuseppe/.qgis/python/plugins', '/usr/share/qgis/python/plugins', '/usr/local/lib/python2.7/dist-packages/pyshp-1.1.4-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/SQLAlchemy-0.7.4-py2.7-linux-i686.egg', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages/Numeric', '/usr/lib/python2.7/dist-packages/PIL', '/usr/lib/python2.7/dist-packages/gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.7', '/usr/lib/pymodules/python2.7/ubuntuone-dev-tools', '/usr/lib/pymodules/python2.7/libubuntuone', '/usr/lib/python2.7/dist-packages/ubuntu-sso-client', '/usr/lib/python2.7/dist-packages/ubuntuone-client', '/usr/lib/python2.7/dist-packages/ubuntuone-control-panel', '/usr/lib/python2.7/dist-packages/ubuntuone-couch', '/usr/lib/python2.7/dist-packages/ubuntuone-file-storage-api', '/usr/lib/python2.7/dist-packages/ubuntuone-installer', '/usr/lib/python2.7/dist-packages/ubuntuone-storage-protocol', '/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode', '/usr/share/qgis/python/plugins/fTools/tools', '/home/giuseppe/Documenti/doc/progetti/mmasgis/gianluca/ProgettoGIS', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/', '/home/giuseppe/eclipse/plugins/org.python.pydev.debug_2.3.0.2011121518/pysrc/']
this is my entities module for SQLite: http://pastebin.com/ya4q9En1
this is the enties module for MySQL: http://pastebin.com/3NypygV4
Can you help me to understand where my mistake is?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不要使用长生不老药。如今,SQLAlchemy 的内置声明式具有其大部分功能,并且您将获得比 Elixir 更好的支持。
Don't use Elixir. Nowadays, SQLAlchemy's built-in declarative has most of its features and you'll get (much) better support than for Elixir.
我将我的应用程序从 elixir 翻译为 sqlalchemy,但我仍然收到相同的错误消息,我开始认为问题不在我的代码中,但在 sqlite db 中,这不是我第一次使用 elixir 创建的数据库有故障。
i translated my application from elixir to sqlalchemy, but I still get the same error message, I begin to think that the problem is not in my code, but in sqlite db this would not be the first time for me that the db created by elixir is faulty.