[GRASS-SVN] r73548 - grass-addons/grass7/imagery/i.segment.stats
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Oct 15 02:14:42 PDT 2018
Author: mlennert
Date: 2018-10-15 02:14:42 -0700 (Mon, 15 Oct 2018)
New Revision: 73548
Modified:
grass-addons/grass7/imagery/i.segment.stats/i.segment.stats.py
Log:
i.segment.stats: avoid too long create table statement
Modified: grass-addons/grass7/imagery/i.segment.stats/i.segment.stats.py
===================================================================
--- grass-addons/grass7/imagery/i.segment.stats/i.segment.stats.py 2018-10-14 21:04:44 UTC (rev 73547)
+++ grass-addons/grass7/imagery/i.segment.stats/i.segment.stats.py 2018-10-15 09:14:42 UTC (rev 73548)
@@ -338,11 +338,11 @@
fsql.write('DROP TABLE %s;' % temporary_vect)
else:
gscript.fatal(_("Table %s already exists. Use --o to overwrite" % temporary_vect))
- create_statement = 'CREATE TABLE ' + temporary_vect + ' (cat int, '
- for header in output_header[1:-1]:
- create_statement += header + ' double precision, '
- create_statement += output_header[-1] + ' double precision);\n'
+ create_statement = 'CREATE TABLE ' + temporary_vect + ' (cat int PRIMARY KEY);\n'
fsql.write(create_statement)
+ for header in output_header[1:]:
+ addcol_statement = 'ALTER TABLE %s ADD COLUMN %s double precision;\n' % (temporary_vect, header)
+ fsql.write(addcol_statement)
for key in output_dict:
if len(output_dict[key]) + 1 == len(output_header):
sql = "INSERT INTO %s VALUES (%s, %s);\n" % (temporary_vect, key, ",".join(output_dict[key]))
More information about the grass-commit
mailing list