Great !, thank you so much my friend. You solved my problem.

best regards,
Leandro.

On Aug 19, 3:13 pm, Andre Smit <freevryh...@gmail.com> wrote:
> In the interim you can use pymssql - eg:
>
> import os, sys, web, json
> import pymssql
>
> prog_dir = os.path.dirname(os.path.abspath(__file__))
> sys.path.append(prog_dir)
>
> urls = (
>     '/'           , 'Index',
>     '/districts'  , 'Districts',
> )
>
> app = web.application(urls, globals())
> application = app.wsgifunc()
>
> templates_dir = os.path.join(prog_dir,'templates/')
> render = web.template.render(templates_dir)
>
> conn = pymssql.connect(host='host', user='user', password='pwd',
> database='db')
>
> class Index:
>     def GET(self):
>         return render.index()
>
> class Districts:
>     def GET(self):
>         res=[]
>         cur = conn.cursor()
>         cur.execute('SELECT DISTNAM FROM DB_DISTRICTS')
>         columns = tuple( [d[0].decode('utf8') for d in cur.description] )
>         for row in cur:
>             res.append(dict(zip(columns, row)))
>         d = {'items':res}
>         web.header('Content-Type', 'application/json')
>         return json.dumps(d)
>
> if __name__ == "__main__":
>     app.run()

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to webpy@googlegroups.com.
To unsubscribe from this group, send email to 
webpy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to