[GRASS-SVN] r67370 - grass/trunk/lib/python/script

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Dec 24 08:55:49 PST 2015


Author: martinl
Date: 2015-12-24 08:55:49 -0800 (Thu, 24 Dec 2015)
New Revision: 67370

Modified:
   grass/trunk/lib/python/script/db.py
Log:
pythonlib: implement db_begin/commit_transaction (see #2759)


Modified: grass/trunk/lib/python/script/db.py
===================================================================
--- grass/trunk/lib/python/script/db.py	2015-12-24 16:16:42 UTC (rev 67369)
+++ grass/trunk/lib/python/script/db.py	2015-12-24 16:55:49 UTC (rev 67370)
@@ -10,7 +10,7 @@
     grass.db_describe(table)
     ...
 
-(C) 2008-2009, 2012 by the GRASS Development Team
+(C) 2008-2015 by the GRASS Development Team
 This program is free software under the GNU General Public
 License (>=v2). Read the file COPYING that comes with GRASS
 for details.
@@ -196,3 +196,23 @@
         return used
     else:
         return None
+
+def db_begin_transaction(driver):
+    """Begin transaction.
+
+    :return: SQL command as string
+    """
+    if driver in ('sqlite', 'pg'):
+        return 'BEGIN'
+    if driver == 'mysql':
+        return 'START TRANSACTION'
+    return ''
+
+def db_commit_transaction(driver):
+    """Commit transaction.
+
+    :return: SQL command as string
+    """
+    if driver in ('sqlite', 'pg', 'mysql'):
+        return 'COMMIT'
+    return ''



More information about the grass-commit mailing list