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

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jun 14 23:01:40 PDT 2013


Author: lucadelu
Date: 2013-06-14 23:01:40 -0700 (Fri, 14 Jun 2013)
New Revision: 56707

Modified:
   grass/trunk/lib/python/pygrass/vector/table.py
Log:
pygrass fix creation of sqlite database where sqlite directory is missing

Modified: grass/trunk/lib/python/pygrass/vector/table.py
===================================================================
--- grass/trunk/lib/python/pygrass/vector/table.py	2013-06-15 05:51:19 UTC (rev 56706)
+++ grass/trunk/lib/python/pygrass/vector/table.py	2013-06-15 06:01:40 UTC (rev 56707)
@@ -22,6 +22,7 @@
 from grass.script.core import warning
 import sys
 import sql
+import os
 
 
 DRIVERS = ('sqlite', 'pg')
@@ -633,7 +634,11 @@
             for t in (np.int8, np.int16, np.int32, np.int64, np.uint8,
                       np.uint16, np.uint32, np.uint64):
                 sqlite3.register_adapter(t, long)
-            return sqlite3.connect(get_path(self.database))
+            dbpath = get_path(self.database)
+            dbdirpath = os.path.split(dbpath)[0]
+            if not os.path.exists(dbdirpath):
+                os.mkdir(dbdirpath)
+            return sqlite3.connect(dbpath)
         elif self.driver == 'pg':
             try:
                 import psycopg2



More information about the grass-commit mailing list