Hi Sreedhar,
On 21 November 2013 14:51, Sreedhar P V <[email protected]> wrote: > Hi Team, > > I am using couchdb for one of my projects and need to import the client > data in couchdb. I have good experience on RDBMS but not on NoSQL. I need > your assistance for the below scenario. > > To export the data I have used below curl command: > *curl -X > GET http://127.0.0.1:5984/testdb/_all_docs?include_docs=true > <http://127.0.0.1:5984/testdb/_all_docs?include_docs=true> > FILE.txt* > > To import the FILE.txt, I used _bulk_docs as below: > *curl -d @FILE.txt -H “Content-type: application/json” -X POST * > *http://localhost:5984/testdb1/_bulk_docs*< > http://localhost:5984/testdb1/_bulk_docs> > > > Below is the sample data for GET with _all_docs. But it is not is not > working for POST with _bulk_docs and it is expecting "docs" in the txt > file. > > {"total_rows":2,"offset":0,"rows":[ > > {"id":"docid1","key":"docid1","value":{"rev":"2-d872217c576ee407a11a5de30ce2bb30"},"doc":{"_id":"docid1","_rev":"2-d872217c576ee407a11a5de30ce2bb30","sdfs":"data"}}, > > {"id":"docid2","key":"docid2","value":{"rev":"1-f58d4c586789ca8e166a53ece008b23b"},"doc":{"_id":"docid2","_rev":"1-f58d4c586789ca8e166a53ece008b23b","f2":"dsvsd"}} > ]} > We need to import the huge data dump which we got from client. Please guide > me to import the huge client data. Thank you in advance. > > > > Thanks, > Sreedhar > don't think in terms of a SQL-dump. The example above looks like you export all documents form testdb and you want to put them into testdb1. For this job, CouchDB provides the _replication mechanism. It would look something like: curl -X POST http://127.0.0.1:5984/_replicate \ -H "content-type:application/json" \ -d ’{"source": "testdb", "target": "testdb1", "create_target": true}’ If you just need a subset of the data, you can use a filter you created create this in a _design document: curl -X PUT http://127.0.0.1:5984/kina/_design/default \ -H "content-type: application/json" \ -d ’{"filters":{ "country": "function(doc, req) { return \"US\" == doc.lang; }" } }’ Then within the replication: curl -X POST http://127.0.0.1:5984/_replicate \ -H "content-type:application/json" \ -d ’{"source": "testdb", "target": "testdb1", "create_target": true, "filter": "default/country"}’ For more info on replication please see http://docs.couchdb.org/en/latest/intro/api.html#replication Cheers Andy -- Andy Wenk Hamburg - Germany RockIt! http://www.couchdb-buch.de http://www.pg-praxisbuch.de GPG fingerprint: C044 8322 9E12 1483 4FEC 9452 B65D 6BE3 9ED3 9588
