def _ConvertFormatToQmark(statement, args):
  """Replaces '%s' with '?'.

  The server actually supports '?' for bind parameters, but the
  MySQLdb implementation of PEP 249 uses '%s'.  Most clients don't
  bother checking the paramstyle member and just hardcode '%s' in
  their statements.  This function converts a format-style statement
  into a qmark-style statement.

  Args:
    statement: A string, a SQL statement.
    args: A sequence of arguments matching the statement's bind variables,
        if any.

  Returns:
    The converted string.
  """
  if args:
    qmarks = tuple('?' * len(args))
    return statement % qmarks
  return statement