On Wed, Jan 14, 2009 at 1:13 AM, Wyatt Baldwin <[email protected]> wrote: > > On Jan 13, 10:45 pm, Jorge Vargas <[email protected]> wrote: >> On Wed, Jan 14, 2009 at 12:36 AM, Wyatt Baldwin >> >> <[email protected]> wrote: >> >> > On Jan 13, 7:07 pm, Jorge Vargas <[email protected]> wrote: >> >> On Tue, Jan 13, 2009 at 3:32 PM, grassoalvaro <[email protected]> >> >> wrote: >> >> >> > Hi, >> >> >> > Can someone tell me how to declare models using sqlalchemy 5.0? >> >> > When i'm trying something like that: >> >> >> > class Worker(object): >> >> > __tablename__ = 'workers' >> >> > id = Column(Integer, primary_key=True) >> >> >> > and next i'm importing it in model.__init__, command paster setup-app >> >> > dosn't create declared table. >> >> >> please review the SA documentation it excels at well everything. >> >> >> You are probably trying to use "SA declarative" which means you >> >> classes need to extend "declarative base" rather than object. As >> >> explained >> >> herehttp://www.sqlalchemy.org/docs/05/ormtutorial.html#creating-table-cla... >> >> > Also, you need to call the method for creating tables >> > (metadata.create_all or something like that); paster doesn't do that >> > for you. Some people do that in websetup.py. >> >> well this is the default in 0.9.7. >> >> Also you should do that in websetup, because calling create_all is >> safe but it makes no sense to call it on each startup if it's never >> going to recreate the tables. while websetup is going to run ones for >> each deployment. > > Thanks for the correction on those defaults in websetup, although it's > possible someone deleted those lines without realizing it. > > Personally, I don't use websetup for creating database tables, because > that isn't part of _web_ setup in my mind. My model lives in a package > separate from my Pylons package/app, which I consider as just a UI. >
agreed, I got a similar setup for one of my projects. I normally use websetup for development (pre-release) after that I let sqlalchemy-migrate take over. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
