我没有看到任何使用Couchbase Python客户端批量插入文档的方法。有关如何使用REST API批量插入文档的任何示例?
我在这里只回答Couchbase,因为你可能知道他们是两个不同的项目,具有不同的功能。
Python SDK无法批量加载数据。
为此,您可以使用: - 标准的set / add方法 - 允许您将文件系统中的数据注入Couchbase Server的cbdocloader命令行工具请参阅:http://www.couchbase.com/docs/couchbase-manual-2.0/couchbase-admin-cmdline-cbdocloader.html
我使用带有Sync Server RESTful API示例JSON的CURL脚本作为属于sync user1的400001.json文件。
{"type": "task-list", "name": "Order400001", "owner": "user1", "_id" : "user1.S100400001" , "Order": { "OrderID": "S100400001", "Status": "In Transit", "Customer": "My Customer", "DateSubmitted": "12/21/2017", "PO": "123455", "SoldToAccount": "0001122333", "ShipToAccount": "0001122333", "Items": [{ "ItemID": "XXX", "ItemStatus": "In Transit", "ItemQty": "2", "ItemPrice": "1500", "ItemDescription": "MODULE XXX US CAN" }, { "ItemID": "XXXG", "ItemStatus": "In Transit", "ItemQty": "2", "ItemPrice": "15000", "ItemDescription": "MODULE XXX US CAN (GOLD)" } ] } }
然后脚本就像这样
curl -X POST“http://user:password@MyCouchBaseSyncServerHost:4984/orders/”-H“accept:application / json”-H“Content-Type:application / json”-H“Authorization:Basic {your key here}”-d @ 401000.json