grr/server/grr_response_server/databases/mysql.py
def _EnforceEncoding(cursor):
  """Enforce a sane UTF-8 encoding for the DB cursor."""
  cursor.execute("SET NAMES '{}' COLLATE '{}'".format(CHARACTER_SET, COLLATION))

  collation_connection = _ReadVariable("collation_connection", cursor)
  if collation_connection != COLLATION:
    raise EncodingEnforcementError(
        "Require MySQL collation_connection of {}, got {}.".format(
            COLLATION, collation_connection))

  collation_database = _ReadVariable("collation_database", cursor)
  if collation_database != COLLATION:
    raise EncodingEnforcementError(
        "Require MySQL collation_database of {}, got {}."
        " To create your database, use: {}".format(
            COLLATION, collation_database, CREATE_DATABASE_QUERY))

  character_set_database = _ReadVariable("character_set_database", cursor)
  if character_set_database != CHARACTER_SET:
    raise EncodingEnforcementError(
        "Require MySQL character_set_database of {}, got {}."
        " To create your database, use: {}".format(
            COLLATION, collation_connection, CREATE_DATABASE_QUERY))

  character_set_connection = _ReadVariable("character_set_connection", cursor)
  if character_set_connection != CHARACTER_SET:
    raise EncodingEnforcementError(
        "Require MySQL character_set_connection of {}, got {}.".format(
            CHARACTER_SET, character_set_connection))
Enforce a sane UTF-8 encoding for the DB cursor.
Enforce a sane UTF-8 encoding for the DB cursor.
Enforce a sane UTF - 8 encoding for the DB cursor .
def _EnforceEncoding(cursor):
  cursor.execute("SET NAMES '{}' COLLATE '{}'".format(CHARACTER_SET, COLLATION))
  collation_connection = _ReadVariable("collation_connection", cursor)
  if collation_connection != COLLATION:
    raise EncodingEnforcementError(
        "Require MySQL collation_connection of {}, got {}.".format(
            COLLATION, collation_connection))
  collation_database = _ReadVariable("collation_database", cursor)
  if collation_database != COLLATION:
    raise EncodingEnforcementError(
        "Require MySQL collation_database of {}, got {}."
        " To create your database, use: {}".format(
            COLLATION, collation_database, CREATE_DATABASE_QUERY))
  character_set_database = _ReadVariable("character_set_database", cursor)
  if character_set_database != CHARACTER_SET:
    raise EncodingEnforcementError(
        "Require MySQL character_set_database of {}, got {}."
        " To create your database, use: {}".format(
            COLLATION, collation_connection, CREATE_DATABASE_QUERY))
  character_set_connection = _ReadVariable("character_set_connection", cursor)
  if character_set_connection != CHARACTER_SET:
    raise EncodingEnforcementError(
        "Require MySQL character_set_connection of {}, got {}.".format(
            CHARACTER_SET, character_set_connection))
def _EnforceEncoding ( cursor ) : cursor . execute ( "SET NAMES '{}' COLLATE '{}'" . format ( CHARACTER_SET , COLLATION ) ) collation_connection = _ReadVariable ( "collation_connection" , cursor ) if collation_connection != COLLATION : raise EncodingEnforcementError ( "Require MySQL collation_connection of {}, got {}." . format ( COLLATION , collation_connection ) ) collation_database = _ReadVariable ( "collation_database" , cursor ) if collation_database != COLLATION : raise EncodingEnforcementError ( "Require MySQL collation_database of {}, got {}." " To create your database, use: {}" . format ( COLLATION , collation_database , CREATE_DATABASE_QUERY ) ) character_set_database = _ReadVariable ( "character_set_database" , cursor ) if character_set_database != CHARACTER_SET : raise EncodingEnforcementError ( "Require MySQL character_set_database of {}, got {}." " To create your database, use: {}" . format ( COLLATION , collation_connection , CREATE_DATABASE_QUERY ) ) character_set_connection = _ReadVariable ( "character_set_connection" , cursor ) if character_set_connection != CHARACTER_SET : raise EncodingEnforcementError ( "Require MySQL character_set_connection of {}, got {}." . format ( CHARACTER_SET , character_set_connection ) )
Enforce a sane UTF-8 encoding for the DB cursor.
Enforce a sane UTF - 8 encoding for the DB cursor .
"""Enforce a sane UTF-8 encoding for the DB cursor."""
cursor