Thank you, Anthony. This is very helpful. Just to confirm though as I don't
want to mess up my existing table, when using db.define_table, it just
creates a "dummy" table within web2py but actual query is done on the real
Table? I don't want to download all the data into the dummy table as there
are millions of rows and constantly changing.
On Sunday, May 29, 2016 at 12:05:52 AM UTC-4, Sammy wrote:
>
> I am a python/web2py newbie. I am trying to create a user friendly web
> search form for clients that connects to our existing Oracle DB and
> executes a query based on search criteria put in the form by users.
>
> For example, user will fill out the form saying first_name = "John" ,
> last_name="Smith" and when they submit, it will output for them all the
> information in the database for John Smith.
>
> I am using DAL to connect to the existing external Oracle DB
>
> my_db = DAL('oracle://username/password@Database')
>
> I am using simple FORM to create the form as I could not figure out how to
> use SQLFORM etc. because those seem to want me to create/define tables
> which I do not want to do as the table already exists and which do not want
> to modify. This is purely a query program.
>
>
> My display_form is something like this
>
> def display_form():
> form = FORM('First Name' INPUT(_name='first_name'),
> 'Last Name' INPUT (_name='last_name'),
> INPUT(_type='submit'))
>
> if form.accepts(request,session):
> session.first_name = request.vars.first_name
> session.last_name = request.vars.last_name
> redirect(URL('next'))
> return dict (form=form)
>
>
> def next():
> sql = "SELECT * from Table 1 where field1 = session.first_name and
> field2 = session.last_name "
>
> rows = my_db.executesql(sql)
> return locals()
>
> Then the next.html is
>
> {{extend 'layout.html'}}
> <h1>Here is your query results.</h1>
> {{=rows}}
>
>
> This works fine except that output is in this format:
>
> [(field1:value1,field2:value2)] etc.
>
> What is the easiest way to output this in a html table output?
>
> I would also like to provide xls output option.
>
> Thanks.
>
>
>
>
>
>
>
--
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.