[GRASS-SVN] r54589 - grass/trunk/lib/python/pygrass/vector

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jan 11 08:37:45 PST 2013


Author: zarch
Date: 2013-01-11 08:37:45 -0800 (Fri, 11 Jan 2013)
New Revision: 54589

Modified:
   grass/trunk/lib/python/pygrass/vector/table.py
Log:
Add create method in the Columns class

Modified: grass/trunk/lib/python/pygrass/vector/table.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/table.py	2013-01-11 16:37:36 UTC (rev 54588)
+++ grass/trunk/lib/python/pygrass/vector/table.py	2013-01-11 16:37:45 UTC (rev 54589)
@@ -302,6 +302,15 @@
         """
         return self.odict.items()
 
+    def create(self, cols):
+        """"""
+        cur = self.conn.cursor()
+        coldef = ',\n'.join(['%s %s' % col for col in cols])
+        cur.execute(sql.CREATE_TAB.format(tname=self.tname, coldef=coldef))
+        self.conn.commit()
+        cur.close()
+        self.update_odict()
+
     def add(self, col_name, col_type):
         """Add a new column to the table. ::
 



More information about the grass-commit mailing list