(self, cmd)
find what ?TABLE?: Searches all columns of all tables for a value

        The find command helps you locate data across your database
        for example to find a string or any references to an id.

        You can specify a like pattern to limit the search to a subset
        of tables (eg specifying 'CUSTOMER%' for all tables beginning
        with CUSTOMER).

        The what value will be treated as a string and/or integer if
        possible.  If what contains % or _ then it is also treated as
        a like pattern.

        This command will take a long time to execute needing to read
        all of the relevant tables.
find what ?TABLE?: Searches all columns of all tables for a value
find what ?TABLE? : Searches all columns of all tables for a value
def command_find(self, cmd):
        """find what ?TABLE?: Searches all columns of all tables for a value

        The find command helps you locate data across your database
        for example to find a string or any references to an id.

        You can specify a like pattern to limit the search to a subset
        of tables (eg specifying 'CUSTOMER%' for all tables beginning
        with CUSTOMER).

        The what value will be treated as a string and/or integer if
        possible.  If what contains % or _ then it is also treated as
        a like pattern.

        This command will take a long time to execute needing to read
        all of the relevant tables.
        """
        if len(cmd) < 1 or len(cmd) > 2:
            raise self.Error("At least one argument required and at most two accepted")
        tablefilter = "%"
        if len(cmd) == 2:
            tablefilter = cmd[1]
        querytemplate = []
        queryparams = []

        def qp():  # binding for current queryparams
            return "?" + str(len(queryparams))

        s = cmd[0]
        if '%' in s or '_' in s:
            queryparams.append(s)
            querytemplate.append("%s LIKE " + qp())
        queryparams.append(s)
        querytemplate.append("%s = " + qp())
        try:
            i = int(s)
            queryparams.append(i)
            querytemplate.append("%s = " + qp())
        except ValueError:
            pass
        querytemplate = " OR ".join(querytemplate)
        for (table, ) in self.db.cursor().execute("SELECT name FROM sqlite_master WHERE type='table' AND name LIKE ?1",
                                                  (tablefilter, )):
            t = self._fmt_sql_identifier(table)
            query = "SELECT * from %s WHERE " % (t, )
            colq = []
            for _, column, _, _, _, _ in self.db.cursor().execute("pragma table_info(%s)" % (t, )):
                colq.append(querytemplate % ((self._fmt_sql_identifier(column), ) * len(queryparams)))
            query = query + " OR ".join(colq)
            self.process_sql(query, queryparams, internal=True, summary=("Table " + table + "\n", "\n"))
def command_find ( self , cmd ) : if len ( cmd ) < 1 or len ( cmd ) > 2 : raise self . Error ( "At least one argument required and at most two accepted" ) tablefilter = "%" if len ( cmd ) == 2 : tablefilter = cmd [ 1 ] querytemplate = [ ] queryparams = [ ] def qp ( ) : # binding for current queryparams return "?" + str ( len ( queryparams ) ) s = cmd [ 0 ] if '%' in s or '_' in s : queryparams . append ( s ) querytemplate . append ( "%s LIKE " + qp ( ) ) queryparams . append ( s ) querytemplate . append ( "%s = " + qp ( ) ) try : i = int ( s ) queryparams . append ( i ) querytemplate . append ( "%s = " + qp ( ) ) except ValueError : pass querytemplate = " OR " . join ( querytemplate ) for ( table , ) in self . db . cursor ( ) . execute ( "SELECT name FROM sqlite_master WHERE type='table' AND name LIKE ?1" , ( tablefilter , ) ) : t = self . _fmt_sql_identifier ( table ) query = "SELECT * from %s WHERE " % ( t , ) colq = [ ] for _ , column , _ , _ , _ , _ in self . db . cursor ( ) . execute ( "pragma table_info(%s)" % ( t , ) ) : colq . append ( querytemplate % ( ( self . _fmt_sql_identifier ( column ) , ) * len ( queryparams ) ) ) query = query + " OR " . join ( colq ) self . process_sql ( query , queryparams , internal = True , summary = ( "Table " + table + "\n" , "\n" ) )