Author: tack
Date: Wed Jun 27 19:19:53 2007
New Revision: 2733

Modified:
   trunk/base/src/db.py

Log:
Use executescript method instead of spawning sqlite3.  Fixes bug where
sqlite lib is installed but not tools.


Modified: trunk/base/src/db.py
==============================================================================
--- trunk/base/src/db.py        (original)
+++ trunk/base/src/db.py        Wed Jun 27 19:19:53 2007
@@ -212,13 +212,12 @@
         self._qcursor = self._db.cursor(Cursor)
 
         if not self.check_table_exists("meta"):
-            self._db.close()
-            self._create_db()
-        else:
-            row = self._db_query_row("SELECT value FROM meta WHERE 
attr='version'")
-            if float(row[0]) < SCHEMA_VERSION_COMPATIBLE:
-                raise SystemError, "Database '%s' has schema version %s; 
required %s" % \
-                                   (self._dbfile, row[0], 
SCHEMA_VERSION_COMPATIBLE)
+            self._db.executescript(CREATE_SCHEMA % SCHEMA_VERSION)
+
+        row = self._db_query_row("SELECT value FROM meta WHERE attr='version'")
+        if float(row[0]) < SCHEMA_VERSION_COMPATIBLE:
+            raise SystemError, "Database '%s' has schema version %s; required 
%s" % \
+                               (self._dbfile, row[0], 
SCHEMA_VERSION_COMPATIBLE)
 
         self._load_object_types()
 
@@ -245,18 +244,6 @@
         return res != None
 
 
-    def _create_db(self):
-        try:
-            os.unlink(self._dbfile)
-        except:
-            pass
-        # FIXME: system may not have sqlite3 binary installed.
-        f = os.popen("sqlite3 %s" % self._dbfile, "w")
-        f.write(CREATE_SCHEMA % SCHEMA_VERSION)
-        f.close()
-        self._open_db()
-
-
     def _register_check_indexes(self, indexes, attrs):
         for cols in indexes:
             if type(cols) not in (list, tuple):

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to