code: def instance(cls, conn, pkg_name='openquake.server.db.schema.upgrades'):
          
          try:
              # upgrader is an UpgradeManager instance defined in the __init__.py
              upgrader = importlib.import_module(pkg_name).upgrader
          except ImportError:
              raise SystemExit(
                  'Could not import %s (not in the PYTHONPATH?)' % pkg_name)
          if not upgrader.read_scripts():
              raise SystemExit(
                  'The upgrade_dir does not contain scripts matching '
                  'the pattern %s' % upgrader.pattern)
          curs = conn.cursor()
          # check if there is already a versioning table
          curs.execute("SELECT name FROM sqlite_master "
                       "WHERE name=%r" % upgrader.version_table)
          versioning_table = curs.fetchall()
          # if not, run the base script and create the versioning table
          if not versioning_table:
              upgrader.init(conn)
              conn.commit()
          return upgrader
docs: Return an :class:`UpgradeManager` instance.
  
          :param conn: a DB API 2 connection
          :param str pkg_name: the name of the package with the upgrade scripts