简体   繁体   English

在融合表中插入超过30条记录时出错

[英]Getting error while inserting more then 30 records to fusion table

Getting Error while inserting more than 30 records to fusion Table. 在融合表中插入30多个记录时出现错误。

Below code is working fine, but record if exist more than 30 records 下面的代码工作正常,但记录是否存在超过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} 无法加载资源:服务器响应状态为403(禁止)Working_Insert_FT_Sample1.htm:33 Object {code: 403, data: Array[1], message: "Rate Limit Exceeded", error: Object}

Check the docs here: https://developers.google.com/fusiontables/docs/v1/sql-reference 在此处检查文档: https : //developers.google.com/fusiontables/docs/v1/sql-reference

The SQL INSERT command can group multiple rows, so you only need one call to the server. SQL INSERT命令可以将多行分组,因此您只需要对服务器进行一次调用。 That should avoid rate limits. 那应该避免速率限制。 Just concatenate the INSERT statements with ';' 只需将INSERT语句连接为';' separator. 分隔器。

See this note! 看到这个笔记!

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. 注意:在一个请求中,只要数据的总大小不超过1 MB并且要添加的表单元格的总数不超过10,000个单元格,您最多可以列出500个用分号分隔的INSERT语句。 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. 如果要插入大量行,请改用import方法,该方法比使用许多SQL INSERT语句更快,更可靠。

Note that the UPDATE and DELETE statements don't allow this! 请注意,UPDATE和DELETE语句不允许这样做! If you need those, you'll have to do more plumbing to your code, eg implementing delays and retries and get the job done in the backend. 如果需要这些,则必须对代码做更多的工作,例如实现延迟和重试,并在后端完成工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM