the str(..) in  str(db(...).select(...)) converts the result of the
slect into CSV.

when you call the action "http://..../my_exporter"; it returns a text
page containing CSV.

If you want the browser to automatically save it in a file you may
want to add two lines:

def my_exporter():
    response.headers['Content-Type']='text/x-csv'
    response.headers['Content-Disposition']='attachment;
filename=yourpreferredfilename.csv" '
    return str(db(...).select(...))

Massimo

On 21 Apr, 09:38, Hans <johann.scheibelho...@easytouch-edv.com> wrote:
> how do I get my_exporter() into csv? is there a web2py function which
> can be called?
>
> On Apr 21, 4:17 pm, mdipierro <mdipie...@cs.depaul.edu> wrote:
>
> > def my_exporter():
> >     return str(db(...).select(...))
>
> > On 21 Apr, 08:52, Hans <johann.scheibelho...@easytouch-edv.com> wrote:
>
> > > I would like to make a controller function that does csv export of a
> > > join select (similar like SQL below but into csv - temporary table ok
> > > if necessary) . How can this be done in web2py?
>
> > > SELECT Persons.LastName,Orders.OrderNo INTO Persons_Order_Backup FROM
> > > Persons INNER JOIN Orders ON Persons.P_Id=Orders.P_Id
>
> > > Thanks,
> > > Hans
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to