In your module, you could have something like:
def insert_record(db):
db.Table1.insert(F1=var2)
And from a model or controller:
from mymodule import insert_record
insert_record(db)
Anthony
On Friday, December 4, 2015 at 9:39:35 AM UTC-5, Aydin S wrote:
>
> This might be asked before and I already found a similar question in here:
> https://groups.google.com/forum/#!topic/web2py/0k0Fvw6fmb8
> but this seemed a bit confusing. How to write on database from within a
> module?
> I have a table defined in db.py (model) as follows:
> db.define_table('Table1',
> Field('F1', 'integer'))
>
> Now I have a variable var1 in the module module1.py that I want to write
> it into F1.
>
> var1=2
>
> Is this similar approach to read a variable from database in a module?
>
>
>
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.