Module: add convenience method to set the version for a module in the database

This commit is contained in:
Brian S. Stephan 2011-05-01 09:29:09 -05:00
parent 14f2a027fe
commit a61fb37394
1 changed files with 12 additions and 0 deletions

View File

@ -215,6 +215,18 @@ class Module(object):
return version
def db_register_module_version(self, modulename, version):
"""Enter the given module name and version number into the database."""
db = self.get_db()
try:
db.execute('UPDATE drbotzo_modules SET version = ? WHERE module = ?', (version, modulename))
db.commit()
except sqlite3.Error as e:
db.rollback()
print("sqlite error: " + str(e))
raise
def db_init(self):
"""
Set up the database tables and so on, if subclass is planning on using it.