_ _ _ _ _ _ _ _ _ _ _ /| |\ / |_ _ _ _ _ _ _ _ _ _| \ \ / \/ \ ___________________ /
An easy interface to CouchDB from R
Note: Check out R4couchdb, another R package to interact with CouchDB.
sofa is built targeting CouchDB v2 or greater.
- Docs: http://docs.couchdb.org/en/latest/index.html
- Installation: http://docs.couchdb.org/en/latest/install/index.html
This may be starting it on your terminal/shell
couchdbOr opening the CouchDB app on your machine, or running it in Docker. Whatever it is, start it up.
You can interact with your CouchDB databases as well in your browser. Navigate to http://localhost:5984/_utils
From CRAN
install.packages("sofa")Development version from GitHub
devtools::install_github("ropensci/sofa")library('sofa')Cushions? What? Since it's couch we gotta use cushions somehow. cushions are a
connection class containing all connection info to a CouchDB instance.
See ?Cushion for help.
As an example, connecting to a Cloudant couch:
z <- Cushion$new(
host = "stuff.cloudant.com",
transport = 'https',
port = NULL,
user = 'foobar',
pwd = 'things'
)Break down of parameters:
host: the base url, without the transport (http/https)path: context path that is appended to the end of the urltransport:httporhttpsport: The port to connect to. Default: 5984. For Cloudant, have to set toNULLuser: User name for the service.pwd: Password for the service, if any.headers: headers to pass in all requests
If you call Cushion$new() with no arguments you get a cushion set up for local
use on your machine, with all defaults used.
x <- Cushion$new()x$ping()
#> $couchdb
#> [1] "Welcome"
#>
#> $version
#> [1] "2.1.1"
#>
#> $features
#> $features[[1]]
#> [1] "scheduler"
#>
#>
#> $vendor
#> $vendor$name
#> [1] "The Apache Software Foundation"Nice, it's working.
#> $ok
#> [1] TRUE
db_create(x, dbname = 'sofadb')
#> $ok
#> [1] TRUEsee if its there now
db_list(x)
#> [1] "cats" "flights" "sofadb" "testing123"doc1 <- '{"name":"sofa","beer":"IPA"}'
doc_create(x, doc1, dbname = "sofadb", docid = "a_beer")
#> $ok
#> [1] TRUE
#>
#> $id
#> [1] "a_beer"
#>
#> $rev
#> [1] "1-a48c98c945bcc05d482bc6f938c89882"doc2 <- '{"name":"sofa","icecream":"rocky road"}'
doc_create(x, doc2, dbname = "sofadb")
#> $ok
#> [1] TRUE
#>
#> $id
#> [1] "901e4bf214fb50db456d3ef8ec0516c9"
#>
#> $rev
#> [1] "1-fd0da7fcb8d3afbfc5757d065c92362c"See the vignettes for more documentation.
- Please report any issues or bugs.
- License: MIT
- Get citation information for
sofain R doingcitation(package = 'sofa') - Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
