[GRASS-SVN] r48355 - in grass/trunk/temporal: t.create t.list t.remove

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Sep 18 18:14:19 EDT 2011


Author: huhabla
Date: 2011-09-18 15:14:19 -0700 (Sun, 18 Sep 2011)
New Revision: 48355

Modified:
   grass/trunk/temporal/t.create/t.create.py
   grass/trunk/temporal/t.list/t.list.py
   grass/trunk/temporal/t.remove/t.remove.py
Log:
Use the new sqlite3 database interface handling method.


Modified: grass/trunk/temporal/t.create/t.create.py
===================================================================
--- grass/trunk/temporal/t.create/t.create.py	2011-09-18 22:12:49 UTC (rev 48354)
+++ grass/trunk/temporal/t.create/t.create.py	2011-09-18 22:14:19 UTC (rev 48355)
@@ -111,18 +111,23 @@
     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()
     main()

Modified: grass/trunk/temporal/t.list/t.list.py
===================================================================
--- grass/trunk/temporal/t.list/t.list.py	2011-09-18 22:12:49 UTC (rev 48354)
+++ grass/trunk/temporal/t.list/t.list.py	2011-09-18 22:14:19 UTC (rev 48355)
@@ -111,9 +111,12 @@
         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 @@
     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:

Modified: grass/trunk/temporal/t.remove/t.remove.py
===================================================================
--- grass/trunk/temporal/t.remove/t.remove.py	2011-09-18 22:12:49 UTC (rev 48354)
+++ grass/trunk/temporal/t.remove/t.remove.py	2011-09-18 22:14:19 UTC (rev 48355)
@@ -52,7 +52,10 @@
     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,13 +77,15 @@
         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()
     main()



More information about the grass-commit mailing list