2015-05-04 40 views
0

將30條以上記錄插入融合表時出現錯誤。將多條30條記錄插入融合表時出現錯誤

下面的代碼工作正常,但記錄是否存在超過30條記錄

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Authorization Request</title> 
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&signed_in=true"></script> 
<script type="text/javascript" src="https://apis.google.com/js/client.js"></script> 
    <script type="text/javascript"> 
     function auth() { 
      var config = { 
       'client_id': '607567025394-rmte05500pvsoj12dsrie1cbei5te506.apps.googleusercontent.com', 
       'scope': 'https://www.googleapis.com/auth/fusiontables', 
       'immediate': false 
      }; 
      gapi.auth.authorize(config, function() { 
       console.log('login complete'); 
       console.log(gapi.auth.getToken()); 
      }); 
     } 
     function insert_row() { 
      gapi.client.setApiKey('AIzaSyAnEhw4Y7n5V7bN226wWo0tHs0Bd7jAzxA'); 

      gapi.client.load('fusiontables', 'v1', function() {     
       var i; 
       for (i = 0; i < 32; i++) { 
        var query = "INSERT INTO 1v228snvOypXSvzbtgZP_nhe_GcmBROV5G7lA0T0P(col0,col1,col2) VALUES ('a','a', 'a')"; 
        gapi.client.fusiontables.query.sql({ sql: query }).execute(function (response) { console.log(response); }); 
       } 
      }); 
     } 
    </script> 
</head> 

<body> 
<button onclick="auth();">Authorize</button> 
<br /> 
<button onclick="insert_row();">Insert Data</button> 
<br /> 
<button onclick="showMap();">Show Map</button> 
<br /> 
<div id="map-canvas"></div> 
</body> 
</html> 

Error:
Failed to load resource: the server responded with a status of 403 (Forbidden) Working_Insert_FT_Sample1.htm:33 Object {code: 403, data: Array[1], message: "Rate Limit Exceeded", error: Object}

回答

0

檢查這裏的文檔:https://developers.google.com/fusiontables/docs/v1/sql-reference

的SQL INSERT命令可以將多個行,所以你只需要一個電話給服務器。這應該避免速率限制。只需將INSERT語句與';'連接起來分隔器。

看到這個筆記!

Note: You can list up to 500 INSERT statements, separated by semicolons, in one request as long as the total size of the data does not exceed 1 MB and the total number of table cells being added does not exceed 10,000 cells. If you are inserting a large number of rows, use the import method instead, which will be faster and more reliable than using many SQL INSERT statements.

請注意,UPDATE和DELETE語句不允許這樣!如果你需要這些,你必須對代碼做更多的管道工作,例如實施延遲和重試,並在後端完成工作。

+0

嗨,感謝您的信息。我想使用導入語句。但我不知道確切的語法。如果可以,那麼你可以請分享任何示例代碼。 (C#,Javascript,Html) – dhamodaran

+0

嗨,請與任何良好的示例代碼一起使用c#或javascript或jquery將excel數據導入到fusion表中。 – dhamodaran