Anthony, I see the advantage of passing db as a parameter to the code
on modules and not relaying to much on current, but what happen when u
can't control the parameters, for example i have a custom Exporter for
a grid in a module:
class MyExporter(ExportClass):
...
on a controller:
exports = dict(xml=False, html=False, csv_with_hidden_cols=False,
csv=False, tsv_with_hidden_cols=False, tsv=False,
json=False, EXT=(MyExporter, 'EXT'),
)
grid = SQLFORM.grid(db.Table1, csv=True, exportclasses=exports)
when configuring the grid i can only give the name of the class, and
it only get the rows on the grid, what if i want to include more data
from my database ? Is there a way around to get access to db other
than current ?
2015-12-04 11:12 GMT-05:00, Anthony <[email protected]>:
> 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.
>
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.