Re: [GRASS-user] Python placeholder (%d) in stdin statement of db.execute
On Thu, Apr 11, 2013 at 8:58 AM, Hamish hamis...@yahoo.com wrote: Johannes wrote: I just tested it again and realized this problem is not related to the placeholder in the python code, but probably an other issue of my pythoncode line nothing is update when use: grass.write_command(db.execute, stdin = UPDATE my points SET prob=100) but using UPDATE my points SET prob=100 in the module GUI works as mentioned already before. Has anyone experience in using db.execute in python with standard input in GRASS7? in GRASS7 you need to add input=- as an option to trigger reading input stdin. (or else stalled module gui headaches..) perhaps this needs to be changed to YES? input-required = NO; No, because db.execute sql=SQL statement works just fine, input is not required. Markus M ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Python placeholder (%d) in stdin statement of db.execute
Hi all, Thank you Hamish, including the option input=- in the python line (for GRASS7) solved the problem. Now I get an update/entry in my attribute table. This is a different behavior from grass65 where this additional option is not needed. /johannes On Thu, Apr 11, 2013 at 11:15 AM, Markus Metz markus.metz.gisw...@gmail.com wrote: On Thu, Apr 11, 2013 at 8:58 AM, Hamish hamis...@yahoo.com wrote: Johannes wrote: I just tested it again and realized this problem is not related to the placeholder in the python code, but probably an other issue of my pythoncode line nothing is update when use: grass.write_command(db.execute, stdin = UPDATE my points SET prob=100) but using UPDATE my points SET prob=100 in the module GUI works as mentioned already before. Has anyone experience in using db.execute in python with standard input in GRASS7? in GRASS7 you need to add input=- as an option to trigger reading input stdin. (or else stalled module gui headaches..) perhaps this needs to be changed to YES? input-required = NO; No, because db.execute sql=SQL statement works just fine, input is not required. Markus M ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Python placeholder (%d) in stdin statement of db.execute
Johannes Radinger wrote: Thank you Hamish, including the option input=- in the python line (for GRASS7) solved the problem. Why read the command from stdin rather than using sql=...? E.g.: grass.write_command(db.execute, sql = UPDATE my points SET prob=100) -- Glynn Clements gl...@gclements.plus.com ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Python placeholder (%d) in stdin statement of db.execute
Oh yes, of course I could use the sql= option... I just overlooked that after moving from GRASS6.5 where this option is not yet existing. Thank you ... /Johannes On Thu, Apr 11, 2013 at 12:47 PM, Glynn Clements gl...@gclements.plus.comwrote: Johannes Radinger wrote: Thank you Hamish, including the option input=- in the python line (for GRASS7) solved the problem. Why read the command from stdin rather than using sql=...? E.g.: grass.write_command(db.execute, sql = UPDATE my points SET prob=100) -- Glynn Clements gl...@gclements.plus.com ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
[GRASS-user] Python placeholder (%d) in stdin statement of db.execute
Hi, I am just struggling with a code line. I want to assign a value to all cells of a defined column. Thus I try to run in python: probvalue=100.0 grass.write_command(db.execute,stdin = UPDATE my_points SET prob=%d %(probvalue)) So far I checked that the string for stdin is generated correctly: UPDATE my_points SET prob=%d %(probvalue) UPDATE my_points SET prob=100 However the column is not updated. When executing the sql line directly in db.execute (GUI) everything works and the column shows 100 for all rows. Any hints? I have tried this on GRASS 7, Ubuntu, Python 2.7.3 /Johannes ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Python placeholder (%d) in stdin statement of db.execute
Hi, I just tested it again and realized this problem is not related to the placeholder in the python code, but probably an other issue of my pythoncode line nothing is update when use: grass.write_command(db.execute, stdin = UPDATE my points SET prob=100) but using UPDATE my points SET prob=100 in the module GUI works as mentioned already before. Has anyone experience in using db.execute in python with standard input in GRASS7? /Johannes ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user