diff options
author | Robin H. Johnson <robbat2@gentoo.org> | 2011-07-08 01:42:29 +0000 |
---|---|---|
committer | Robin H. Johnson <robbat2@gentoo.org> | 2011-07-08 01:42:46 +0000 |
commit | 5a95efa1da01fecb1516a94263cacc3744e7dab4 (patch) | |
tree | a0e0e79e1bab21baa8e9c22da6325f5ea7d5ea2d /dbgenerator | |
parent | CherryPy 3.1 requires that engine.start is NOT called anymore for mod_python ... (diff) | |
download | packages-3-5a95efa1da01fecb1516a94263cacc3744e7dab4.tar.gz packages-3-5a95efa1da01fecb1516a94263cacc3744e7dab4.tar.bz2 packages-3-5a95efa1da01fecb1516a94263cacc3744e7dab4.zip |
Improve version detection code.
Diffstat (limited to 'dbgenerator')
-rw-r--r-- | dbgenerator/database.py | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/dbgenerator/database.py b/dbgenerator/database.py index 94ae0e2..6698d90 100644 --- a/dbgenerator/database.py +++ b/dbgenerator/database.py @@ -549,20 +549,23 @@ class SQLPackageDatabase(object): def schema_is_current(self): """Check if the database schema version matches the version expected by the sourcecode""" + result = False + detected_version = None try: sql = self.sql['SELECT_schema_is_current'] self.cursor.execute(sql) entries = self.cursor.fetchall() - if entries is None: - return False - current_schema = entries[0][0] - return current_schema == self.schema_version + if entries is not None: + current_schema = entries[0][0] + result = (current_schema == self.schema_version) + detected_version = current_schema) except IndexError: - return False + pass except self.db.OperationalError: - return False + pass except self.db.ProgrammingError: - return False + pass + return (result, detected_version) def _preparesql(self): """Prepare all SQL statements for the relevant DB backend""" @@ -614,7 +617,8 @@ class SQLitePackageDB(SQLPackageDatabase): self.cursor = self.db.cursor() self._preparesql() - if not self.schema_is_current(): + schema_check = self.schema_is_current() + if not schema_check[0]: print 'Schema is outdated, flushing!' self.initdb = True if self.initdb: |