Elixir create_all() 不创建数据库和表
我正在使用 Elixir 0.7.1 、 Sqlalchemy 0.6beta1 、 MySQLdb 1.2.2 。 我的模型文件“model.py”如下所示:
from elixir import *
from datetime import datetime
class Author:
first_name = Field(Unicode(64))
last_name = Field(Unicode(64))
class Article:
title = Field(Unicode(64))
class Category:
name = Field(Unicode(64))
setup_all()
metadata.bind = "mysql://user:pass@localhost/dbname"
metadata.bind.echo = True
create_all()
metadata.create_all()
执行后: python model.py ,没有创建表,也没有抛出错误。 以下是向 SQL 服务器发出的 echo 命令的列表:
2010-03-06 19:50:22,004 INFO sqlalchemy.engine.base.Engine.0x...6c4c SELECT DATABASE()
2010-03-06 19:50:22,004 INFO sqlalchemy.engine.base.Engine.0x...6c4c ()
2010-03-06 19:50:22,005 INFO sqlalchemy.engine.base.Engine.0x...6c4c SHOW VARIABLES LIKE 'character_set%%'
2010-03-06 19:50:22,005 INFO sqlalchemy.engine.base.Engine.0x...6c4c ()
2010-03-06 19:50:22,006 INFO sqlalchemy.engine.base.Engine.0x...6c4c SHOW VARIABLES LIKE 'lower_case_table_names'
2010-03-06 19:50:22,006 INFO sqlalchemy.engine.base.Engine.0x...6c4c ()
2010-03-06 19:50:22,007 INFO sqlalchemy.engine.base.Engine.0x...6c4c SHOW COLLATION
2010-03-06 19:50:22,007 INFO sqlalchemy.engine.base.Engine.0x...6c4c ()
2010-03-06 19:50:22,009 INFO sqlalchemy.engine.base.Engine.0x...6c4c SHOW VARIABLES LIKE 'sql_mode'
2010-03-06 19:50:22,010 INFO sqlalchemy.engine.base.Engine.0x...6c4c ()
我已经搜索了解决方案,但找不到任何解决方案。
I'm using Elixir 0.7.1 , Sqlalchemy 0.6beta1 , MySQLdb 1.2.2.
My Model file 'model.py' looks like this:
from elixir import *
from datetime import datetime
class Author:
first_name = Field(Unicode(64))
last_name = Field(Unicode(64))
class Article:
title = Field(Unicode(64))
class Category:
name = Field(Unicode(64))
setup_all()
metadata.bind = "mysql://user:pass@localhost/dbname"
metadata.bind.echo = True
create_all()
metadata.create_all()
after executing : python model.py , no tables are created and no errors are thrown.
Here is a list of echo'd commands that are issued to the SQL server:
2010-03-06 19:50:22,004 INFO sqlalchemy.engine.base.Engine.0x...6c4c SELECT DATABASE()
2010-03-06 19:50:22,004 INFO sqlalchemy.engine.base.Engine.0x...6c4c ()
2010-03-06 19:50:22,005 INFO sqlalchemy.engine.base.Engine.0x...6c4c SHOW VARIABLES LIKE 'character_set%%'
2010-03-06 19:50:22,005 INFO sqlalchemy.engine.base.Engine.0x...6c4c ()
2010-03-06 19:50:22,006 INFO sqlalchemy.engine.base.Engine.0x...6c4c SHOW VARIABLES LIKE 'lower_case_table_names'
2010-03-06 19:50:22,006 INFO sqlalchemy.engine.base.Engine.0x...6c4c ()
2010-03-06 19:50:22,007 INFO sqlalchemy.engine.base.Engine.0x...6c4c SHOW COLLATION
2010-03-06 19:50:22,007 INFO sqlalchemy.engine.base.Engine.0x...6c4c ()
2010-03-06 19:50:22,009 INFO sqlalchemy.engine.base.Engine.0x...6c4c SHOW VARIABLES LIKE 'sql_mode'
2010-03-06 19:50:22,010 INFO sqlalchemy.engine.base.Engine.0x...6c4c ()
I have searched for a solution and couldn't find any.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
那么,您必须从 Entity 基类(或您选择的使用 EntityMeta 元类的另一个基类)继承。
Well, you have to inherit from the Entity base class (or from another base class of your choosing that use the EntityMeta metaclass).