On Sat, Dec 27, 2008 at 11:16:43AM -0800, Daniel Fetchinson wrote:
> I have a table with lots of fields, around 40-50, all the same type,
> integer, and since I'm experimenting with the right number (maybe 40
> is enough, maybe 60 is needed) I'm looking for a way to define these
> fields programmatically as opposed to hard wiring it into the
> SQLObject subclass. Storing the 40-60 integers as a python list and
> storing it as a single field in the table is not really an option
> because I need to search these integers.
> 
> What would be the best way of going about this?

   I have a very wide table with a hundred of similar named columns. The
number of columns is fixed, the names are hardwired, but still I don't want
to list all these columns manually. Well, I just add them at runtime, at
the first import of my model.py:

class Plate(SQLObject):
   # regular columns...

# Layout
for row in CELL_IDXS:
    for column in STRIP_IDXS:
        Plate.sqlmeta.addColumn(StringCol(name="Layout" + '%s%s' % (row, 
column),
            length=255, default=None))

# Samples (IDs)
for row in CELL_IDXS:
    for column in STRIP_IDXS:
        Plate.sqlmeta.addColumn(IntCol(name="Sample" + '%s%s' % (row, column),
            default=None))

   Does it help?

Oleg.
-- 
     Oleg Broytmann            http://phd.pp.ru/            p...@phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.

------------------------------------------------------------------------------
_______________________________________________
sqlobject-discuss mailing list
sqlobject-discuss@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss

Reply via email to