MySQL Utilities 1.5 Manual  /  ...  /  mysql.utilities.command.grep — Search Databases for Objects

6.3.1 mysql.utilities.command.grep — Search Databases for Objects

This module provides utilities to search for objects on a server. The module defines a set of object types that can be searched by searching the fields of each object. The notion of an object field is very loosely defined and means any names occurring as part of the object definition. For example, the fields of a table include the table name, the column names, and the partition names (if it is a partitioned table).


The following constants denote the object types that can be searched.

  • mysql.utilities.command.grep.ROUTINE

  • mysql.utilities.command.grep.EVENT

  • mysql.utilities.command.grep.TRIGGER

  • mysql.utilities.command.grep.TABLE

  • mysql.utilities.command.grep.DATABASE

  • mysql.utilities.command.grep.VIEW

  • mysql.utilities.command.grep.USER

The following constant is a sequence of all the object types that are available. It can be used to generate a version-independent list of object types that can be searched; for example, options and help texts.

  • mysql.utilities.command.grep.OBJECT_TYPES


class mysql.utilities.command.grep.ObjectGrep(pattern[, database_pattern=None, types=OBJECT_TYPES, check_body=False, use_regexp=False])

Search MySQL server instances for objects where the name (or content, for routines, triggers, or events) matches a given pattern.

sql() - string

Return the SQL code for executing the search in the form of a SELECT statement.

Returns: SQL code for executing the operation specified by the options.
Return type: string

execute(connections[, output=sys.output, connector=mysql.connector])

Execute the search on each of the connections in turn and print an aggregate of the result as a grid table.

  • connections Sequence of connection specifiers to send the query to

  • output File object to use for writing the result

  • connector Connector to use for connecting to the servers

User Comments
Sign Up Login You must be logged in to post a comment.