[SQLObject] Re: Changing table structure via SQLOBject
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Chris G. <ch...@il...> - 2004-03-07 05:59:31
|
Uhm, just read my last post here... It's a little ambiguous. "Chris Gahan" <ch...@il...> wrote in message news:c2eb69$emk$1...@se...... > [...] you know what I think would be cool? > A function that you can run after you've modified the attributes of an > SQLObject which will update the database's table to add the new attributes > and changes WITHOUT requiring you to lose all of your data (or to have to > change the table by hand)! By "modified the attributes", I mean "change the definition of an SQLObject subclass", not "change the values of the attributes" :) Here's an example... if my original definition was: def SuperVillain(SQLObject): realname = StringCol() coolVillainName = StringCol() nicknameTauntedByInSchool = StringCol() ...and then I changed it thusly: def SuperVillain(SQLObject): realname = StringCol() coolVillainName = StringCol() nicknameTauntedByInSchool = StringCol(default='Stupid') evilCatchphrase = EnumCol(enumValues=["You will all feel my wrath!", "None can withstand my awesome power!", "Muahahahahaha!!"]) ...and then ran the new (currently fictitious) function "SuperVillain.updateTableSchema()", it would add an evil_catchphrase column. Yeah. That's what I mean. :) |