Options:
 * :t - Specifies version/time of db. Defaults to latest version
509270
def database_info(dbname, options = {})
      version = options.fetch(:t, '-')
      get db_url(dbname, version) + "/", :Accept => 'application/edn'
    end
1211871
def type_in_db(self, tp, params):
        
        tw = TypeWrapper(tp, params)
        return self.version_db.is_versioned(tw)
758791
def current_ts?(time)
      (current_version.time <= time) &&
        (next_version.nil? || (next_version.time < time))
    end
1099095
async def version(self, tp, params, version=None, elem=None):
        
        if self.writing:
            return await self.set_version(tp, params, version, elem)
        else:
            return await self.get_version(tp, params)
703395
def cache_options(sql = nil)
      options = Influxer.config.cache.dup
      options[:expires_in] = (options[:cache_now_for] || 60) if sql =~ /\snow\(\)/
      options
    end
539846
@Override
    public boolean setVersion(String version) {
        // Update the version column in the database. This is a little weird looking because we want
        // to avoid modifying the database if the version didn't change, and because the row might
        // not exist yet.
        SQLiteStorageEngine storage = store.getStorageEngine();
        boolean hasView;
        Cursor cursor = null;
        try {
            String sql = "SELECT name, version FROM views WHERE name=?";
            String[] args = {name};
            cursor = storage.rawQuery(sql, args);
            hasView = cursor.moveToNext();
        } catch (SQLException e) {
            Log.e(Log.TAG_VIEW, "Error querying existing view name " + name, e);
            return false;
        } finally {
            if (cursor != null)
                cursor.close();
        }

        if (!hasView) {
            // no such record, so insert
            ContentValues insertValues = new ContentValues();
            insertValues.put("name", name);
            insertValues.put("version", version);
            insertValues.put("total_docs", 0);
            storage.insert("views", null, insertValues);
            createIndex();
            return true; // created new view
        }

        ContentValues updateValues = new ContentValues();
        updateValues.put("version", version);
        updateValues.put("lastSequence", 0);
        updateValues.put("total_docs", 0);
        String[] whereArgs = {name, version};
        int rowsAffected = storage.update("views",
                updateValues,
                "name=? AND version!=?",
                whereArgs);
        return (rowsAffected > 0);
    }
986451
def set_version(new_version_number=None, old_version_number=''):
    
    if new_version_number is None:
        return ValueError

    import fileinput
    import sys

    file = join('timezonefinder', '__init__.py')

    for line in fileinput.input(file, inplace=1):
        if old_version_number in line:
            line = line.replace(old_version_number, new_version_number)
        sys.stdout.write(line)
1055448
private boolean checkDatabaseVersion(String databaseName) {
        final Version softwareVersion = this.requiredProductVersions.get(databaseName);
        if (softwareVersion == null) {
            throw new IllegalStateException("No version number is configured for: " + databaseName);
        }

        final Version databaseVersion = this.versionDao.getVersion(databaseName);
        if (databaseVersion == null) {
            throw new IllegalStateException(
                    "No version number is exists in the database for: " + databaseName);
        }

        return softwareVersion.equals(databaseVersion);
    }
714386
def upgrade(cfg):
    """"""
    db_node = cfg["db"]
    old_db_elems = ["host", "name", "port", "pass", "user", "dialect"]
    has_old_db_elems = [x in db_node for x in old_db_elems]

    if any(has_old_db_elems):
        print("Old database configuration found. "
              "Converting to new connect_string. "
              "This will *not* be stored in the configuration automatically.")
        cfg["db"]["connect_string"] = \
            "{dialect}://{user}:{password}@{host}:{port}/{name}".format(
                dialect=cfg["db"]["dialect"]["value"],
                user=cfg["db"]["user"]["value"],
                password=cfg["db"]["pass"]["value"],
                host=cfg["db"]["host"]["value"],
                port=cfg["db"]["port"]["value"],
                name=cfg["db"]["name"]["value"])
390249
def version(user=None, password=None, host=None, port=None, database='admin', authdb=None):
    '''
    
    '''
    conn = _connect(user, password, host, port, authdb=authdb)
    if not conn:
        err_msg = "Failed to connect to MongoDB database {0}:{1}".format(host, port)
        log.error(err_msg)
        return (False, err_msg)

    try:
        mdb = pymongo.database.Database(conn, database)
        return _version(mdb)
    except pymongo.errors.PyMongoError as err:
        log.error('Listing users failed with error: %s', err)
        return six.text_type(err)
24469
private static function database_set_version($package, \Datetime $version) {
		$db = \Skeleton\Database\Database::get();
		$table = Config::$database_table;

		$data = [
			'package' => $package,
			'version' => $version->format('Y-m-d H:i:s'),
		];

		$row = $db->get_row('SELECT * FROM `' . $table . '` WHERE package=?', [ $package ]);
		if ($row === null) {
			$db->insert($table, $data);
		} else {
			$db->update($table, $data, 'package=' . $db->quote($package));
		}
	}
1367081
function(instance, opt){
      var previousVersion = instance._previousDataValues;
      var currentVersion = instance.dataValues;

      // Disallow change of revision
      instance.set(options.revisionAttribute, instance._previousDataValues[options.revisionAttribute]);

      // Get diffs
      var diffs = getDifferences(previousVersion, currentVersion, options.exclude);

      if(diffs && diffs.length > 0){
         instance.set(options.revisionAttribute, (instance.get(options.revisionAttribute) || 0) + 1);
         if(!instance.context){
            instance.context = {};
         }
         instance.context.diffs = diffs;
      }
   }
512123
public void dbSchemaCheckVersion() {
    try {
      String dbVersion = getDbVersion();
      if (!ProcessEngine.VERSION.equals(dbVersion)) {
        throw LOG.wrongDbVersionException(ProcessEngine.VERSION, dbVersion);
      }

      List<String> missingComponents = new ArrayList<>();
      if (!isEngineTablePresent()) {
        missingComponents.add("engine");
      }
      if (dbSqlSessionFactory.isDbHistoryUsed() && !isHistoryTablePresent()) {
        missingComponents.add("history");
      }
      if (dbSqlSessionFactory.isDbIdentityUsed() && !isIdentityTablePresent()) {
        missingComponents.add("identity");
      }
      if (dbSqlSessionFactory.isCmmnEnabled() && !isCmmnTablePresent()) {
        missingComponents.add("case.engine");
      }
      if (dbSqlSessionFactory.isDmnEnabled() && !isDmnTablePresent()) {
        missingComponents.add("decision.engine");
      }

      if (!missingComponents.isEmpty()) {
        throw LOG.missingTableException(missingComponents);
      }

    } catch (Exception e) {
      if (isMissingTablesException(e)) {
        throw LOG.missingActivitiTablesException();
      } else {
        if (e instanceof RuntimeException) {
          throw (RuntimeException) e;
        } else {
          throw LOG.unableToFetchDbSchemaVersion(e);
        }
      }
    }
  }
835608
def set_db_opts(self, dbname="mta4", credentials=True):
        
        from jcvi.utils.db import valid_dbconn, get_profile

        self.add_option("--db", default=dbname, dest="dbname",
                help="Specify name of database to query [default: %default]")
        self.add_option("--connector", default="Sybase", dest="dbconn",
                choices=valid_dbconn.keys(), help="Specify database connector [default: %default]")
        hostname, username, password = get_profile()
        if credentials:
            self.add_option("--hostname", default=hostname,
                    help="Specify hostname [default: %default]")
            self.add_option("--username", default=username,
                    help="Username to connect to database [default: %default]")
            self.add_option("--password", default=password,
                    help="Password to connect to database [default: %default]")
        self.add_option("--port", type="int",
                help="Specify port number [default: %default]")
352621
def last(args, dbtype=None):
    
    p = OptionParser(last.__doc__)
    p.add_option("--dbtype", default="nucl",
                 choices=("nucl", "prot"),
                 help="Molecule type of subject database")
    p.add_option("--path", help="Specify LAST path")
    p.add_option("--mask", default=False, action="store_true", help="Invoke -c in lastdb")
    p.add_option("--format", default="BlastTab",
                 choices=("TAB", "MAF", "BlastTab", "BlastTab+"),
                 help="Output format")
    p.add_option("--minlen", default=0, type="int",
                 help="Filter alignments by how many bases match")
    p.add_option("--minid", default=0, type="int", help="Minimum sequence identity")
    p.set_cpus()
    p.set_params()

    opts, args = p.parse_args(args)

    if len(args) != 2:
        sys.exit(not p.print_help())

    subject, query = args
    path = opts.path
    cpus = opts.cpus
    if not dbtype:
        dbtype = opts.dbtype
    getpath = lambda x: op.join(path, x) if path else x
    lastdb_bin = getpath("lastdb")
    lastal_bin = getpath("lastal")

    subjectdb = subject.rsplit(".", 1)[0]
    run_lastdb(infile=subject, outfile=subjectdb + ".prj", mask=opts.mask, \
              lastdb_bin=lastdb_bin, dbtype=dbtype)

    u = 2 if opts.mask else 0
    cmd = "{0} -u {1}".format(lastal_bin, u)
    cmd += " -P {0} -i3G".format(cpus)
    cmd += " -f {0}".format(opts.format)
    cmd += " {0} {1}".format(subjectdb, query)

    minlen = opts.minlen
    minid = opts.minid
    extra = opts.extra
    assert minid != 100, "Perfect match not yet supported"
    mm = minid / (100 - minid)

    if minlen:
        extra += " -e{0}".format(minlen)
    if minid:
        extra += " -r1 -q{0} -a{0} -b{0}".format(mm)
    if extra:
        cmd += " " + extra.strip()

    lastfile = get_outfile(subject, query, suffix="last")
    sh(cmd, outfile=lastfile)
1068404
def drop_alembic_version_table():
    """"""
    if _db.engine.dialect.has_table(_db.engine, 'alembic_version'):
        alembic_version = _db.Table('alembic_version', _db.metadata,
                                    autoload_with=_db.engine)
        alembic_version.drop(bind=_db.engine)
192406
def set_update_time(self, update_time=None):
        
        if update_time and isinstance(update_time, (datetime.datetime,)):
            self.last_update_time = update_time
        else:
            self.last_update_time = datetime.datetime.utcnow()