views:

167

answers:

1

Hey, 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.

+1  A: 

Well, you have to inherit from the Entity base class (or from another base class of your choosing that use the EntityMeta metaclass).

class Author(Entity):
    first_name = Field(Unicode(64))
    last_name = Field(Unicode(64))

class Article(Entity):
    title = Field(Unicode(64))

class Category(Entity):
    name = Field(Unicode(64))
gdementen