def find(self, pattern):
        """Find pages in database."""

        if not os.path.exists(environ.index_db):
            raise RuntimeError("can't find index.db")

        conn = sqlite3.connect(environ.index_db)
        cursor = conn.cursor()
        selected = cursor.execute(
            'SELECT * FROM "%s" WHERE name '
            'LIKE "%%%s%%" ORDER BY LENGTH(name)'
            % (environ.source, pattern)).fetchall()

        pat = re.compile('(%s)' % re.escape(pattern), re.I)

        if selected:
            for name, url, std in selected:
                if os.isatty(sys.stdout.fileno()):
                    print(pat.sub(r'\033[1;31m\1\033[0m', name) +
                          (' \033[1;33m[%s]\033[0m' % std if std else ''))
                else:
                    print(name + (' [%s]' % std if std else ''))
        else:
            raise RuntimeError('%s: nothing appropriate.' % pattern)
Find pages in database.