Bläddra i källkod

pygrass fix creation of sqlite database where sqlite directory is missing

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@56707 15284696-431f-4ddb-bdfa-cd5b030d7da7
Luca Delucchi 12 år sedan
förälder
incheckning
c542313730
1 ändrade filer med 6 tillägg och 1 borttagningar
  1. 6 1
      lib/python/pygrass/vector/table.py

+ 6 - 1
lib/python/pygrass/vector/table.py

@@ -22,6 +22,7 @@ from grass.script.db import db_table_in_vector
 from grass.script.core import warning
 import sys
 import sql
+import os
 
 
 DRIVERS = ('sqlite', 'pg')
@@ -633,7 +634,11 @@ class Link(object):
             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