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

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Jan 20 09:19:10 PST 2013


Author: zarch
Date: 2013-01-20 09:19:10 -0800 (Sun, 20 Jan 2013)
New Revision: 54717

Modified:
   grass/trunk/lib/python/pygrass/vector/table.py
Log:
Fix update_odict method of Columns class for an unexisting table using postgresql connection

Modified: grass/trunk/lib/python/pygrass/vector/table.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/table.py	2013-01-20 15:42:37 UTC (rev 54716)
+++ grass/trunk/lib/python/pygrass/vector/table.py	2013-01-20 17:19:10 UTC (rev 54717)
@@ -193,12 +193,16 @@
             cur = self.conn.cursor()
             cur.execute("SELECT oid,typname FROM pg_type")
             diz = dict(cur.fetchall())
-            cur.execute(sql.SELECT.format(cols='*', tname=self.tname))
-            descr = cur.description
             odict = OrderedDict()
-            for column in descr:
-                name, ctype = column[:2]
-                odict[name] = diz[ctype]
+            import psycopg2 as pg
+            try:
+                cur.execute(sql.SELECT.format(cols='*', tname=self.tname))
+                descr = cur.description
+                for column in descr:
+                    name, ctype = column[:2]
+                    odict[name] = diz[ctype]
+            except pg.ProgrammingError:
+                pass
             self.odict = odict
         else:
             # is a sqlite connection
@@ -851,6 +855,8 @@
         try:
             sqlc = sql_code if sql_code else self.filters.get_sql()
             cur = self.conn.cursor()
+            #if hasattr(self.cur, 'executescript'):
+            #    return cur.executescript(sqlc)
             return cur.execute(sqlc)
         except:
             raise ValueError("The SQL is not correct:\n%r" % sqlc)
@@ -865,5 +871,4 @@
         cur = self.conn.cursor()
         vals = list(values)
         vals.append(key)
-        print self.columns.update_str, vals
         return cur.execute(self.columns.update_str, vals)
\ No newline at end of file



More information about the grass-commit mailing list