EXPAND ALL
  • Home

normalize_mysql

Replaces constants with '?' placeholder.Outputs the normalized query along with the values of the parameters

Returns: STRING

The normalized query with the values of the parameters in the query as JSON. Available keys: ['query', 'params', 'error']. Error will be non-empty if the query could not be normalized.

Arguments

VariableTypeDescription
sql_stringSTRINGThe MySQL query string
cmd_codeINT64The MySQL command code for this sql request.

Examples:

# Normalize the SQL query.
# px.mysql_command_code(3) == 'Query'
df.normalized_sql_json = px.normalize_mysql("SELECT * FROM test WHERE prop=@a AND prop2='abcd'", 3)
# Pluck the relevant values from the json.
# Value: 'SELECT * FROM test WHERE prop=@a AND prop2=?'
df.normed_query = px.pluck(df.normalized_sql_json, 'query')
# Value: ['abcd']
df.params = px.pluck(df.normalized_sql_json, 'params')
This site uses cookies to provide you with a better user experience. By using Pixie, you consent to our use of cookies.