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.

Reply via email to