Thanks for SQLObject, it's great!
I have used SQLObject with one project and I am working on my second. Still,
I am rather new to Python and totally new to SQLobject so excuse me if this
question is dumb.
I am looking for a way to created a table from a list of values. Say I have:
headers = ['bbd_id', 'co_name1', 'address1', 'address2', 'city',
'state', 'zip5', 'zip4', 'first_name', 'surname', 'telephone']
Is there a way to define my class attributes from this list?
I tried playing with the _columns like this:
#.....snip...does not work......
class mail_list(SQLObject):
def __init__(self, headers):
for h in headers:
self._columns.append("StringCol("+h+")")
mail_list.createTable()
#....snip
But I was unsure on how to pass headers while initiating the class with
'createTable'. I end up with a table with only one field, id. Is there a way
to inherit these values from elsewhere?
Then I have made a string of arguments to use when initialize the new
instance:
new_values = "bbd_id='1', co_name1='big corp', address1='123
AnyStreet', address2='', city='Sample', state='ST', zip5='12345',
zip4='9999', first_name='Bob', surname='Villa', telephone='555-1212'"
I plan on simply creating each row with the string:
row = mail_list.new.new(new_values)
Thanks in advance for any help.
SQLObject-0.5.2
Python 2.3
|