In module1.py:

def myfunction(var1=2):
    db = current.db
    db.table1.insert(F1=var1)
    db.commit() # if this call is not a part of a HTTP request
    return



2015-12-04 9:39 GMT-05:00, Aydin S <hsofl...@gmail.com>:
> 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 web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Yoel Benítez Fonseca
http://redevil.cubava.cu/
$ python -c "import this"

-- 
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/d/optout.

Reply via email to