hi, given some vector with a attribute table column defined as integer/double.
task: updating the attribute table by a WHERE ... AND ... clause. some code snippet Python 2.7.4 (default, Apr 6 2013, 19:54:46) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. import grass.script as grass A = "testdbupdate" # (<- vector name) A testdbupdate B = "testupdate" # (<- column name to be updated) B testupdate C = "id" # (<- column name for the WHERE ... AND clause) C id grass.run_command("db.execute", sql = "UPDATE %s SET %s='*'", WHERE "%s < 2" AND "%s > 3" % (A, B, C, C)) File "<input>", line 1 grass.run_command("db.execute", sql = "UPDATE %s SET %s='*'", WHERE "%s < 2" AND "%s > 3" % (A, B, C, C)) ^ SyntaxError: invalid syntax grass.run_command("db.execute", sql = "UPDATE %s SET %s='*'", WHERE "%s<2" AND "%s>3" % (A, B, C, C)) File "<input>", line 1 grass.run_command("db.execute", sql = "UPDATE %s SET %s='*'", WHERE "%s<2" AND "%s>3" % (A, B, C, C)) ^ SyntaxError: invalid syntax grass.run_command("db.execute", sql = "UPDATE %s SET %s='*'", WHERE "%s<2 AND %s>3" % (A, B, C, C)) File "<input>", line 1 grass.run_command("db.execute", sql = "UPDATE %s SET %s='*'", WHERE "%s<2 AND %s>3" % (A, B, C, C)) ^ SyntaxError: invalid syntax grass.run_command("db.execute", sql = "UPDATE %s SET %s='*'", WHERE '%s<2 AND %s>3' % (A, B, C, C)) File "<input>", line 1 grass.run_command("db.execute", sql = "UPDATE %s SET %s='*'", WHERE '%s<2 AND %s>3' % (A, B, C, C)) ^ SyntaxError: invalid syntax I've tried some python command variants .... any pointers for a working command? thanks. ----- best regards Helmut -- View this message in context: http://osgeo-org.1560.x6.nabble.com/how-to-use-the-WHERE-AND-in-a-python-script-using-variables-tp5139315.html Sent from the Grass - Dev mailing list archive at Nabble.com. _______________________________________________ grass-dev mailing list grass-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-dev