Cliff, No worries - I understand where are you coming from. From the beginning I had 3 options of table structure for my app. I have decided consciously that I am going to use one table as a storage for program parameters. Where each new program brings 1 to N new columns/fields to the existing param_table. So I have done lots of work based on this 'architecture' thinking that it is super simple to add column to existing table and now I come to the task where I want to implement it - I have got stack. I wonder what is wrong in this approach from your point of you? What is the maximum number of fields I can theoretically add to the table?
On Friday, February 7, 2014 4:31:49 PM UTC+3, Cliff Kachinske wrote: > > Andrey, > > Not to be negative, but why do you want to do this? > > On Friday, February 7, 2014 8:07:10 AM UTC-5, Andrey K wrote: >> >> Thanks Anthony for your concise answer! >> I have tried it in the app code - it did not work, giving me no error. I >> have tried your code in the terminal and it looks the code does not create >> new table field. Any idea why it does not work? Maybe its my db settings? I >> use sqlite db. Your help would very helpful to me as all my app >> dependent on this function. >> >> Here is my trial in a terminal: >> >> >>> from gluon import DAL, Field >> >>> db = DAL('sqlite://se2.sqlite',check_reserved=['postgres', >> 'postgres_nonreserved'],pool_size=10,lazy_tables=True, migrate=True, >> fake_migrate=False) >> >> >>> ta_args = dict(format='%(f1)s') >> >> >> >>> db.define_table('ta', Field('f1', 'string'), **ta_args) >> >>> db._tables >> ['ta'] >> >>> db.ta._fields >> >> ['id', 'f1'] >> #if understand correctly here I am trying to add new field 'newfield' to >> the ta table. >> >>> db.define_table('ta', db.ta,Field('newfield', 'string', default = >> 'abc'),redefine=True, **ta_args) >> >>> db.ta._fields >> #it giving me no change in db.table field list >> >> ['id', 'f1'] >> >> On Thursday, February 6, 2014 4:41:29 PM UTC+3, Anthony wrote: >>> >>> The safest way is probably to redefine the whole table. >>> >>> *models/dp.py:* >>> >>> tA_args = dict(format='%(f1)s', ...) >>> db.define_table('tA', >>> Field('f1', 'string'), >>> **tA_args) >>> >>> *controllers/default.py:* >>> >>> db.define_table('tA', db.tA, >>> Field('newfield'), >>> redefine=True, **tA_args) >>> >>> Anthony >>> >> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.