Try to get a list of db names
333769
def _get_db_names(self):
        
        query = """
            SELECT datname FROM pg_database
            WHERE datallowconn AND NOT datistemplate
            AND NOT datname='postgres' AND NOT datname='rdsadmin' ORDER BY 1
        """
        conn = self._connect(self.config['dbname'])
        cursor = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
        cursor.execute(query)
        datnames = [d['datname'] for d in cursor.fetchall()]
        conn.close()

        # Exclude `postgres` database list, unless it is the
        # only database available (required for querying pg_stat_database)
        if not datnames:
            datnames = ['postgres']

        return datnames
1327966
def db_exists(name, **client_args):
    '''
    
    '''
    if name in [db['name'] for db in list_dbs(**client_args)]:
        return True

    return False
954516
def _get_sql(filename):
    """"""
    with open(os.path.join(SQL_DIR, filename), 'r') as f:
        return f.read()
958014
def get_table_list(dbconn):
    
    cur = dbconn.cursor()
    cur.execute("SELECT name FROM sqlite_master WHERE type='table';")
    try:
        return [item[0] for item in cur.fetchall()]
    except IndexError:
        return get_table_list(dbconn)
1139412
def _GetTableNames(self, database):
    
    table_names = []
    for esedb_table in database.tables:
      table_names.append(esedb_table.name)

    return table_names
469121
def as_list(self):
        """"""
        go_id = self.go_term.id
        
        qual_str = '|'.join(self.qualifier)
        db_ref_str = '|'.join(self.db_ref)
        taxon_str = '|'.join(self.taxon)

        # with_from is currently left as a string
        # with_from = '|'.join()
        with_from_str = self.with_from or ''
        db_name_str = self.db_name or ''
        db_syn_str = '|'.join(self.db_syn)
        ext_str = '|'.join(self.ext)
        product_id_str = self.product_id or ''

        l = [
            self.db,
            self.db_id,
            self.db_symbol,
            qual_str,
            go_id,
            db_ref_str,
            self.ev_code,
            with_from_str,
            self.aspect,
            db_name_str,
            db_syn_str,
            self.db_type,
            taxon_str,
            self.date,
            self.assigned_by,
            ext_str,
            product_id_str,
        ]
        return l
894601
function (DB_name, name, onDone, prefix) {

	//LOG.warn('init ' + DB_name + ' collection: ' + name, 'SR.DB');

	if (l_DBclient.hasOwnProperty(DB_name) === false) {
		LOG.error('DBclient not init or authenticated for DB [' + DB_name + ']', 'SR.DB');
		return UTIL.safeCall(onDone, false);
	}

	// check if already init
	if (l_getCollection(name, undefined, DB_name) !== undefined) {
		LOG.warn('DB [' + DB_name + '] collection [' + name + '] already loaded', 'SR.DB');
		LOG.warn('please check if different codes are using the same collection names', 'SR.DB');
		// NOTE: we assume double declaration of collection name is ok
		return UTIL.safeCall(onDone, true);
	}

	// build collection name to prefix with server name or a specified prefix
	var collection_name = (prefix || SR.Settings.SERVER_INFO.name) + ':' + name;

	// original simple version
	//var collection_name = name;

	l_DBclient[DB_name].collection(collection_name,
		function (err, collection) {
			if (err) {
				LOG.error(err, 'SR.DB');
				LOG.error('init DB [' + DB_name + ' ] collection [' + collection_name + '] error', 'SR.DB');
				UTIL.safeCall(onDone, false);
			} else {
				// store each name as a collection entry in collection object
				// collection name, instance(conn) , cache (idx by _id)
				var msg = 'init DB [' + DB_name + '] collection [' + collection_name + '] success';
				LOG.debug(msg, 'SR.DB');
				if (l_clts.hasOwnProperty(DB_name) === false) {
					l_clts[DB_name] = {};
				}

				// store collection instance into a two-level map
				l_clts[DB_name][name] = collection;

				// attach entity list to collection (for object caching)
				l_clts[DB_name][name].cache = {};

				UTIL.safeCall(onDone, true);
			}
		}
	);
}
1322939
def db_check(name,
             table=None,
             **connection_args):
    '''
    
    '''
    ret = []
    if table is None:
        # we need to check all tables
        tables = db_tables(name, **connection_args)
        for table in tables:
            log.info('Checking table \'%s\' in db \'%s\'..', name, table)
            ret.append(__check_table(name, table, **connection_args))
    else:
        log.info('Checking table \'%s\' in db \'%s\'..', name, table)
        ret = __check_table(name, table, **connection_args)
    return ret
1187535
def getLayoutNames(self):
		""""""

		if self._db == '':
			raise FMError, 'No database was selected'

		request = []
		request.append(uu({'-db': self._db }))
		request.append(uu({'-layoutnames': '' }))

		result = self._doRequest(request)
		result = FMResultset.FMResultset(result)

		layoutNames = []
		for layoutName in result.resultset:
			layoutNames.append(string.lower(layoutName['LAYOUT_NAME']))

		return layoutNames
1301553
function dbName(str) {
  if (!str) return str;
  str = str.replace(/[A-Z]/g, $0 => `_${$0.toLowerCase()}`);
  if (str[0] === '_') return str.slice(1);
  return str;
}
181732
String getDatabaseName(String dbName) {
        if (mFileNameMap == null) {
            return null;
        }
        String name = mFileNameMap.get(dbName);
        if (name == null && dbName != null) {
            name = mFileNameMap.get(null);
        }
        if (name == null) {
            return null;
        }
        if (mDatabaseHook != null) {
            try {
                dbName = mDatabaseHook.databaseName(dbName);
            } catch (IncompatibleClassChangeError e) {
                // Method not implemented.
            }
        }
        return dbName;
    }
587885
def get_table_names(connection):
	
	cursor = connection.cursor()
	cursor.execute("SELECT name FROM sqlite_master WHERE type == 'table'")
	return [name for (name,) in cursor]
1259265
def quote_names(db, names):
    """"""
    c = db.cursor()
    c.execute("SELECT pg_catalog.quote_ident(n) FROM pg_catalog.unnest(%s::text[]) n", [list(names)])
    return [name for (name,) in c]
565812
def list_databases(self, instance, limit=None, marker=None):
        """"""
        return instance.list_databases(limit=limit, marker=marker)
1124041
def db_getString(self, db_name, key):
        
        warnings.warn('deprecated', DeprecationWarning)
        return (yield from self.rpc_call('db_getString', [db_name, key]))
1091673
def get_partitions_by_names(self, db_name, tbl_name, names):
    
    self.send_get_partitions_by_names(db_name, tbl_name, names)
    return self.recv_get_partitions_by_names()
813943
def db_exists(name, **connection_args):
    '''
    
    '''
    dbc = _connect(**connection_args)
    if dbc is None:
        return False
    cur = dbc.cursor()
    # Warn: here db identifier is not backtyped but should be
    #  escaped as a string value. Note also that LIKE special characters
    # '_' and '%' should also be escaped.
    args = {"dbname": name}
    qry = "SHOW DATABASES LIKE %(dbname)s;"
    try:
        _execute(cur, qry, args)
    except MySQLdb.OperationalError as exc:
        err = 'MySQL Error {0}: {1}'.format(*exc.args)
        __context__['mysql.error'] = err
        log.error(err)
        return False
    cur.fetchall()
    return cur.rowcount == 1