On Wednesday, December 21, 2016 at 7:05:57 AM UTC-8, yarecki wr wrote: > > I have a table defined where I would need to export one column to SMB > share as a txt file automatically when a new row gets added? How can this > be achieved? Hope it's clear from the question I'm beggining with web2py > and python for that matter :) >
A starting point for an answer would be: You query should as the database for just that column. You then convert the Rows object that's returned (roughly speaking, an array of dicts of values that were found in that column) into text. The simplest-to-describe method for that is to loop through the Rows object, and write the value of the column (because the value is in a dict, you have to use the fieldname to get the value). Something like: openmyfile() rows=db(mytlable.id > 0).select("bestfieldever"); for row in rows: write2myfile(row["bestfieldever"] closemyfile() You can turn the Rows object into a list object, and perhaps writing the list object works, so you don't have to do the for loop yourself. <URL:http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#as_dict-and-as_list> You may also be able to use the CSV export tool: <URL:http://web2py.com/books/default/chapter/29/06/the-database-abstraction-layer#CSV--one-Table-at-a-time-> Good luck! /dps -- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.