[GRASS-SVN] r68029 - in grass-addons/grass7/db: . db.join
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Mar 9 07:33:48 PST 2016
Author: neteler
Date: 2016-03-09 07:33:47 -0800 (Wed, 09 Mar 2016)
New Revision: 68029
Added:
grass-addons/grass7/db/Makefile
Modified:
grass-addons/grass7/db/db.join/db.join.py
Log:
db.join addon: fix addcolumn code
Added: grass-addons/grass7/db/Makefile
===================================================================
--- grass-addons/grass7/db/Makefile (rev 0)
+++ grass-addons/grass7/db/Makefile 2016-03-09 15:33:47 UTC (rev 68029)
@@ -0,0 +1,8 @@
+MODULE_TOPDIR = ..
+
+SUBDIRS = \
+ db.join
+
+include $(MODULE_TOPDIR)/include/Make/Dir.make
+
+default: subdirs
Property changes on: grass-addons/grass7/db/Makefile
___________________________________________________________________
Added: svn:mime-type
+ text/x-makefile
Added: svn:eol-style
+ native
Modified: grass-addons/grass7/db/db.join/db.join.py
===================================================================
--- grass-addons/grass7/db/db.join/db.join.py 2016-03-09 10:08:11 UTC (rev 68028)
+++ grass-addons/grass7/db/db.join/db.join.py 2016-03-09 15:33:47 UTC (rev 68029)
@@ -12,6 +12,8 @@
# License (>=v2). Read the file COPYING that comes with GRASS
# for details.
#
+# TODO: use "BEGIN TRANSACTION"
+# or f.write("{}\n".format(grass.db_begin_transaction(fi['driver']))) ?
#############################################################################
#%module
@@ -147,12 +149,14 @@
# add only the new column to the table
if colname not in all_cols_tt:
- try:
- grass.run_command('db.addcolumn', table=table,
- columns=colspec)
- except CalledModuleError:
- grass.fatal(_("Error creating column <%s>") % colname)
+ p = grass.feed_command('db.execute', input = '-', database = database, driver = driver)
+ p.stdin.write("ALTER TABLE %s ADD COLUMN %s" % (table, colspec))
+ grass.debug("ALTER TABLE %s ADD COLUMN %s" % (table, colspec))
+ p.stdin.close()
+ if p.wait() != 0:
+ grass.fatal(_("Unable to add column <%s>.") % colname)
+
stmt = template.substitute(table=table, column=column,
otable=otable, ocolumn=ocolumn,
colname=colname)
More information about the grass-commit
mailing list