How to insert documents in bulk into Couchbase?

I have not seen an option to insert documents in bulk using the Couchbase Python client. Any example on how to insert documents in bulk using REST api?

+3


source to share


2 answers


I am only responsible for Couchbase as you probably know that these are two different projects with different functionality.

The Python SDK has no way to bulk load data.



To do this, you can use: - standard set / add methods - the cbdocloader command line tool that allows you to enter data from the file system into the Couchbase Server: http://www.couchbase.com/docs/couchbase-manual-2.0 /couchbase-admin-cmdline-cbdocloader.html

+2


source


I have used CURL script with RESTful Sync Server API JSON example as 400001.json file belonging to sync user1.

    {"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)"
            }
        ]
    }
}



Then a script like this

curl -X POST " http: // user: password @ MyCouchBaseSyncServerHost : 4984 / orders / " -H "accept: application / json" -H "Content-Type: application / json" -H "Authorization: Primary {your key here } "-d @ 401000.json

0


source







All Articles