Re: [SQLObject] Altering/updating a database
SQLObject is a Python ORM.
Brought to you by:
ianbicking,
phd
From: Oleg B. <ph...@ph...> - 2011-03-04 14:00:47
|
On Fri, Mar 04, 2011 at 12:49:50PM +0000, Timothy W. Grove wrote: > It seems to me that there should be a simple way to add the attribute to > the class if the column has been added already, or not if it has been > added through updating There is no a simple way. You have to create the table class without the column, and then look into the database to determine if the column is there. You can use the same mechanism SQLObject uses to implement fromDatabase: connection.columnsFromSchema(tableName, soClass); the result is a list of SOCol instances. > I've also experimented with reading the class description from the > database using "class sqlmeta: fromDatabase = True" but I don't think > this works with the sqlite backend. Well, database introspection can't be precise; for example, SQLObject cannot determine on per-column basis if you want StringCol or UnicodeCol. SQLObject's implementation is also quite simple, it cannot determine ForeignKeys, e.g. But it can get the list of columns with their types. Do you have problems with that? Oleg. -- Oleg Broytman http://phdru.name/ ph...@ph... Programmers don't die, they just GOSUB without RETURN. |