Shortcut to check if complex exists in our database.
7897
def complex_exists(self, complex: str) -> bool:
        
        try:
            self.check_complex(complex)
        except exceptions.RumetrComplexNotFound:
            return False

        return True
722388
def table_exists(self, tablename: str) -> bool:
        """"""
        # information_schema is ANSI standard
        sql = """
            SELECT COUNT(*)
            FROM information_schema.tables
            WHERE table_name=?
            AND table_schema={}
        """.format(self.get_current_schema_expr())
        row = self.fetchone(sql, tablename)
        return True if row[0] >= 1 else False
951123
public function tableExists()
    {
        $dbh    = $this->db();
        $table  = $this->table();
        $driver = $dbh->getAttribute(PDO::ATTR_DRIVER_NAME);
        if ($driver === self::SQLITE_DRIVER_NAME) {
            $query = sprintf('SELECT name FROM sqlite_master WHERE type = "table" AND name = "%s";', $table);
        } else {
            $query = sprintf('SHOW TABLES LIKE "%s"', $table);
        }

        $this->logger->debug($query);
        $sth    = $dbh->query($query);
        $exists = $sth->fetchColumn(0);

        return !!$exists;
    }
589479
final public static function exists($keys): bool {
		
		// initialize some vars
		$db			= Database::getInstance();
		$tableKey	= (array)static::TABLE_KEY;
		$conds		= array();

		foreach ($tableKey as $field) {
			$conds[] = $field . ' = ?';
		}
		
		$query = 'SELECT COUNT(1) FROM `' . static::TABLE_NAME . '` WHERE ' . implode(' AND ', $conds);
		
		// execute and return value
		return (bool)Database::load($query, (array)$keys, PAIR_DB_COUNT);
		
	}
384961
def exists(self):
        
        cur = self.connection.query("SHOW DATABASES LIKE '{database}'".format(database=self.database))
        return cur.rowcount > 0
5489
def _check_exists(database: Database, table: LdapObjectClass, key: str, value: str):
    
    try:
        get_one(table, Q(**{key: value}), database=database)
        return True
    except ObjectDoesNotExist:
        return False
511957
def exists(self, query, **args):
        
        return bool(self.find(query, **args).limit(1).count())
900846
def check_complex(self, complex: str) -> bool:
        
        self.check_developer()
        if complex in self._checked_complexes:
            return True

        try:
            self.get('developers/{developer}/complexes/{complex}/'.format(
                developer=self.developer,
                complex=complex,
            ))
        except exceptions.Rumetr404Exception:
            raise exceptions.RumetrComplexNotFound('Unknown complex — maybe you should create one?')

        self._checked_complexes.add(complex)
        return True
253942
def if_exists(self):
        
        if self.model._has_counter:
            raise IfExistsWithCounterColumn('if_exists cannot be used with tables containing counter columns')
        clone = copy.deepcopy(self)
        clone._if_exists = True
        return clone
1161195
def verify(self):
        
        collections = self.get_data_collections()

        allIDs = []
        for coll in collections:
            IDs = self.noteDB[coll].find({"ID": {"$exists": True}},
                                         {"ID": 1, "_id": 0})
            for ID in IDs:
                allIDs.append(int(ID["ID"]))

        query = {"currentMax": {"$exists": True}}
        maxID = int(self.noteDB['IDs'].find_one(query)["currentMax"])
        query = {"unusedIDs": {"$exists": True}}
        unusedIDs = self.noteDB['IDs'].find_one(query)["unusedIDs"]
        unusedIDs = [int(ii) for ii in unusedIDs]

        unusedIDsMatch = True
        for ID in allIDs:
            if ID in unusedIDs:
                unusedIDsMatch = False

        maxIDMatch = True
        if maxID is not max(allIDs):
            maxIDMatch = False

        if maxIDMatch and unusedIDsMatch:
            print "Database is valid"
        elif not maxIDMatch and not unusedIDsMatch:
            print "Database not valid, max ID and unused IDs are incorrent"
        elif not maxIDMatch:
            print "Database not valid, max ID is incorrent"
        elif not unusedIDsMatch:
            print "Database not valid, unusedIDs is incorrent"
1162052
protected function checkTableExists()
  {
    $m = $this->getManager();

    $q = 'SHOW TABLES LIKE "' . $m->getPrefix() . $this->getTable() . '"';

    return (bool)$m->query($q)->rowCount();
  }
389784
def _recursively_lookup_complex(self, complex_id):
        """"""
        assert complex_id in self.complex_map

        expanded_agent_strings = []
        expand_these_next = [complex_id]
        while len(expand_these_next) > 0:
            # Pop next element
            c = expand_these_next[0]
            expand_these_next = expand_these_next[1:]

            # If a complex, add expanding it to the end of the queue
            # If an agent string, add it to the agent string list immediately
            assert c in self.complex_map
            for s in self.complex_map[c]:
                if s in self.complex_map:
                    expand_these_next.append(s)
                else:
                    expanded_agent_strings.append(s)
        return expanded_agent_strings
134180
def database_exist(self):
        
        binds = {}
        for key, engine in self.keys_engines():
            key = key if key else 'default'
            binds[key] = self._database_exist(engine)
        return binds
1302219
def _check_object_exists(self):
        
        if not DB.get_keys(self.key):
            raise KeyError("Object with key '{}' not exist".format(self.key))
1215288
public function checkDbTableExists() {
		$ds = $this->getDataSource();
		$existsTables = $ds->listSources();
		if (empty($existsTables)) {
			return false;
		}

		$schemaList = [];
		$schemaCheckingList = [''];
		$schemaCheckingListCfg = $this->_modelConfigInstaller->getListSchemaChecking();
		if (!empty($schemaCheckingList)) {
			$schemaCheckingList = array_merge($schemaCheckingList, $schemaCheckingListCfg);
		}
		foreach ($schemaCheckingList as $schemaCheckingListItem) {
			$name = null;
			$path = null;
			$file = null;
			$connection = null;
			$plugin = null;

			if (preg_match('/[\s\b]?\-\-name\s+(\w+)/', $schemaCheckingListItem, $matches) && (count($matches) == 2)) {
				list($plugin, $name) = pluginSplit($matches[1]);
			} elseif (preg_match('/^(\w+)/', $schemaCheckingListItem, $matches) && (count($matches) == 2)) {
				$name = $matches[1];
			}

			if (preg_match('/[\s\b]?(?:\-p|\-\-plugin)\s+(\w+)/', $schemaCheckingListItem, $matches) && (count($matches) == 2)) {
				$plugin = $matches[1];
			}

			if (preg_match('/[\s\b]?(?:\-c|\-\-connection)\s+(\w+)/', $schemaCheckingListItem, $matches) && (count($matches) == 2)) {
				$connection = $matches[1];
			}

			if (preg_match('/[\s\b]?\-\-path\s+(\w+)/', $schemaCheckingListItem, $matches) && (count($matches) == 2)) {
				$path = $matches[1];
			}

			if (preg_match('/[\s\b]?\-\-file\s+(\w+)/', $schemaCheckingListItem, $matches) && (count($matches) == 2)) {
				$file = $matches[1];
			}

			if (!empty($name)) {
				$file = Inflector::underscore($name);
			} elseif (empty($file)) {
				$file = 'schema.php';
			}

			if (strpos($file, '.php') === false) {
				$file .= '.php';
			}

			if (!empty($plugin) && empty($name)) {
				$name = $plugin;
			}

			$name = Inflector::camelize($name);
			$schemaList[] = compact('name', 'path', 'file', 'connection', 'plugin');
		}

		$existsTables = array_flip($existsTables);
		foreach ($schemaList as $schemaListItem) {
			$Schema = new CakeSchema($schemaListItem);
			$oldSchema = $Schema->load();
			if (!$oldSchema) {
				return false;
			}

			$diffTables = array_diff_key($oldSchema->tables, $existsTables);
			if (!empty($diffTables)) {
				return false;
			}
			unset($Schema);
		}

		return true;
	}
187156
def has_run?(filename)
      if @db.schema_schema_evolution_manager_exists?
        query = "select count(*) from %s.%s where filename = '%s'" % [Db.schema_name, @table_name, filename]
        @db.psql_command(query).to_i > 0
      else
        false
      end
    end
1372978
def exists_table(self, name, database=None):
        
        return len(self.list_tables(like=name, database=database)) > 0