Bläddra i källkod

Use the new sqlite3 database interface handling method.

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@48355 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 13 år sedan
förälder
incheckning
cf09eed75d
3 ändrade filer med 26 tillägg och 14 borttagningar
  1. 9 4
      temporal/t.create/t.create.py
  2. 8 6
      temporal/t.list/t.list.py
  3. 9 4
      temporal/t.remove/t.remove.py

+ 9 - 4
temporal/t.create/t.create.py

@@ -111,17 +111,22 @@ def main():
     if type == "stvds":
         sp = grass.space_time_vector_dataset(id)
 
-    if sp.is_in_db() and grass.overwrite() == False:
+    dbif = grass.sql_database_interface()
+    dbif.connect()
+
+    if sp.is_in_db(dbif) and grass.overwrite() == False:
         grass.fatal("Space time " + sp.get_new_map_instance(None).get_type() + " dataset <" + name + "> is already in the database. Use the overwrite flag.")
 
-    if sp.is_in_db() and grass.overwrite() == True:
+    if sp.is_in_db(dbif) and grass.overwrite() == True:
         grass.info("Overwrite space time " + sp.get_new_map_instance(None).get_type() + " dataset <" + name + "> and unregister all maps.")
-        sp.delete()
+        sp.delete(dbif)
 
     grass.info("Create space time " + sp.get_new_map_instance(None).get_type() + " dataset.")
 
     sp.set_initial_values(granularity=gran, temporal_type=temporaltype, semantic_type=semantic, title=title, description=descr)
-    sp.insert()
+    sp.insert(dbif)
+
+    dbif.close()
 
 if __name__ == "__main__":
     options, flags = grass.core.parser()

+ 8 - 6
temporal/t.list/t.list.py

@@ -111,9 +111,12 @@ def main():
         sp = grass.raster3d_dataset(id)
     if type == "vector":
         sp = grass.vector_dataset(id)
-        
+
+    dbif = grass.sql_database_interface()
+    dbif.connect()
+
     # Insert content from db
-    sp.select()
+    sp.select(dbif)
 
     # Create the sql selection statement
     # Table name
@@ -133,10 +136,9 @@ def main():
     if where:
         sql += " WHERE " + where
 
-    sp.base.connect()
-    sp.base.cursor.execute(sql)
-    rows = sp.base.cursor.fetchall()
-    sp.base.close()
+    dbif.cursor.execute(sql)
+    rows = dbif.cursor.fetchall()
+    dbif.close()
 
     # Print the query result to stout
     if rows:

+ 9 - 4
temporal/t.remove/t.remove.py

@@ -52,7 +52,10 @@ def main():
     grass.create_temporal_database()
     
     mapset =  grass.gisenv()["MAPSET"]
-    
+
+    dbif = grass.sql_database_interface()
+    dbif.connect()
+
     for name in names.split(","):
         name = name.strip()
         # Check for the mapset in name
@@ -74,12 +77,14 @@ def main():
         if type == "vector":
             ds = grass.vector_dataset(id)
 
-        if ds.is_in_db() == False:
+        if ds.is_in_db(dbif) == False:
             grass.fatal(ds.get_type() + " dataset <" + name + "> not found in temporal database")
 
         # We need to read some data from the temporal database
-        ds.select()
-        ds.delete()
+        ds.select(dbif)
+        ds.delete(dbif)
+
+    dbif.close()
 
 if __name__ == "__main__":
     options, flags = grass.core.parser()