Here is an example;  (which can be downloaded from 
http://bulkanix.pastebin.com/f18d411e8
)

import web

urls = [
 '/', 'index',
]

#NOTE: change dbn to your database type mysql or postgresql, db to
your database name
web.config.db_parameters = dict(dbn='mysql', user='', pw='', db='')
web.webapi.internalerror = web.debugerror

# Database debugging - prints DB requests
web.config.db_printing = True

class index:
    def GET(self):
        print """
<form method="post" action="/">
    <input name="name" type="text" tabindex="1" size="15" />
    <input type="submit" value="submit"/>
</form>"""
        return

    def POST(self):
        i = web.input()

        name = i.name

        # for demonstrating purpose of web.py, the value i pass in
will always
        # return a value
        user = web.select('users',where='name = $name',vars = locals())
[0]

        print  "<h1>Hello %s</h1> your id is %d" %(user.name, user.id)
        return

if __name__ == '__main__':
    web.run(urls, globals(), web.reloader)

what it does is when you access it (GET), you see a form with one
input box
you write (a name in this case) you submit it (POST) gets the name
from the
POST request (i = web.input) checks database to see if there is a user
with
the same name (names are unique) and then displays the id for the
user. My
database (mysql) has a table called user with three two columns id
(primary key) and
name.

Anyway my coding style above my be "bad" as i just learnt web.py last
week
in which i created an "Job Tracking" type application for my work. But
for
demonstration purposes it suffices (i hope)

Hope it helps

On Nov 24, 5:08 pm, dineshv <[EMAIL PROTECTED]>
wrote:
> Hello!
>
> We are familiar with Python but our problem right now is building the
> web site using (any) one of the Python web frameworks.  It was
> suggested that we begin with WebPy but to be honest all the frameworks
> are baffling.  This evening I reviewed the PHP material and it all
> looks so much more easier and simpler.
>
> Anyway, our prototype requirement needs are not complex ie. enter a
> query on a blank page, go get the results from a database (we don't
> need help with the sql), and display the results.  That's it!
>
> Any input on how to get this done in WebPy would be appreciated.
> Thank-you!
>
> Dinesh
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to