|
From: Peter D. <pet...@gm...> - 2011-06-13 17:48:19
|
I just started using SQLObject and I would like to use it with Flask. So I figured I would separate the models from the actual database working, similar to what Django does.
I create the following function to open up the models files and create the tables:
import inspect
import models
def __init__(self):
members = inspect.getmembers(models, inspect.isclass)
for name, cls in members:
if cls.__module__ == 'models':
try:
cls.createTable(ifNotExists=True)
except OperationalError, e:
raise OperationalError(e)
When I get to this model
class Event(SQLObject):
event_id = IntCol( unique = True )
describ = StringCol()
date = DateTimeCol(default = DateTimeCol.now)
organizer = ForeignKey("Organizer", default=None)
sponsers = MultipleJoin("Sponser")
attendees = RelatedJoin("Attendee")
I get the following error:
conxt.#sql-d58_2b' (errno: 150)
If I run it again, everything works fine. The first time through the table is created, but not the the related tables.
|