【问题标题】:Getting error while inserting more then 30 records to fusion table向融合表插入 30 多条记录时出错
【发布时间】:2015-05-04 18:43:56
【问题描述】:

向融合表插入超过 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>

错误:
加载资源失败:服务器响应状态为 403(禁止) Working_Insert_FT_Sample1.htm:33 Object {code: 403, data: Array[1], message: "Rate Limit Exceeded", error: Object}

【问题讨论】:

    标签: javascript c#


    【解决方案1】:

    在此处查看文档:https://developers.google.com/fusiontables/docs/v1/sql-reference

    SQL INSERT 命令可以对多行​​进行分组,因此您只需一次调用服务器。那应该避免速率限制。只需将 INSERT 语句与 ';' 连接起来分隔器。

    请参阅此说明!

    注意:您最多可以列出 500 个 INSERT 语句,以 分号,在一个请求中,只要数据的总大小不 不超过 1 MB 并且要添加的表格单元的总数 不超过 10,000 个细胞。如果要插入大量行, 改用import方式,更快更可靠 而不是使用许多 SQL INSERT 语句。

    请注意,UPDATE 和 DELETE 语句不允许这样做!如果你需要这些,你将不得不对你的代码做更多的管道,例如实施延迟和重试并在后端完成工作。

    【讨论】:

    • 您好,感谢您的信息。我想使用导入语句。但我不知道确切的语法。如果可能的话,请您分享任何示例代码。 (C#、Javascript、Html)
    • 您好,请分享使用 c# 或 javascript 或 jquery 将 excel 数据导入融合表的任何好的示例代码。
    猜你喜欢
    • 2011-10-26
    • 1970-01-01
    • 1970-01-01
    • 2012-08-25
    • 2021-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多