tech:notes_couchdb
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| tech:notes_couchdb [2025/03/24 15:06] – créée - modification externe 127.0.0.1 | tech:notes_couchdb [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # Notes CouchDB | ||
| + | |||
| + | Voir aussi : | ||
| + | * MongoDB | ||
| + | * ArangoDB | ||
| + | * RethinkDB | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | |||
| + | Voir : | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * Kivik & kivik CLI tool | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * http:// | ||
| + | |||
| + | |||
| + | |||
| + | Code : | ||
| + | * https:// | ||
| + | ~~~bash | ||
| + | docker run -d --name my-couchdb -p 5984:5984 -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=password couchdb: | ||
| + | ~~~ | ||
| + | |||
| + | WebUI Fauxton Futon | ||
| + | * http:// | ||
| + | |||
| + | Ping | ||
| + | ~~~bash | ||
| + | curl http:// | ||
| + | ~~~ | ||
| + | |||
| + | Pour Supervision | ||
| + | ~~~bash | ||
| + | curl http:// | ||
| + | ~~~ | ||
| + | |||
| + | Show databases | ||
| + | ~~~bash | ||
| + | curl http:// | ||
| + | ~~~ | ||
| + | |||
| + | Create database | ||
| + | ~~~bash | ||
| + | curl -X PUT http:// | ||
| + | ~~~ | ||
| + | |||
| + | Show all docs | ||
| + | ~~~bash | ||
| + | curl http:// | ||
| + | curl http:// | ||
| + | ~~~ | ||
| + | |||
| + | Upload binary file | ||
| + | ~~~bash | ||
| + | curl -X PUT http:// | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | |||
| + | |||
| + | Opérandes de comparaison | ||
| + | * https:// | ||
| + | |||
| + | |||
| + | https:// | ||
| + | |||
| + | https:// | ||
| + | ~~~javascript | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | ~~~ | ||
| + | |||
| + | Bases | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| + | |||
| + | Insert - Post | ||
| + | ~~~bash | ||
| + | curl -H ' | ||
| + | |||
| + | curl -H ' | ||
| + | ~~~ | ||
| + | |||
| + | Select - Get | ||
| + | ~~~bash | ||
| + | curl -d ' | ||
| + | |||
| + | curl -d ' | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | ] | ||
| + | } | ||
| + | ' | ||
| + | |||
| + | curl -d ' | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | }, | ||
| + | " | ||
| + | " | ||
| + | ] | ||
| + | } | ||
| + | ' | ||
| + | |||
| + | curl -X PUT http:// | ||
| + | -d ' | ||
| + | " | ||
| + | ~~~ | ||
| + | |||
| + | ~~~javascript | ||
| + | function(doc){ | ||
| + | emit(doc.table.id, | ||
| + | } | ||
| + | |||
| + | |||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | ~~~ | ||
| + | |||
| + | |||
| + | ## Programmation - db drivers | ||
| + | |||
| + | Obsolète ? | ||
| + | ~~~bash | ||
| + | pip install -U celery-with-couchdb | ||
| + | pip install -U celery[couchdb] | ||
| + | ~~~ | ||
| + | |||
| + | https:// | ||
| + | https:// | ||
| + | |||
| + | |||
| + | https:// | ||
| + | ~~~bash | ||
| + | pip install Flask-CouchDB | ||
| + | ~~~ | ||
| + | |||
| + | ~~~python | ||
| + | import couchdb | ||
| + | couch = couchdb.Server(' | ||
| + | |||
| + | db = couch[' | ||
| + | count = 0 | ||
| + | for docid in db.view(' | ||
| + | i = docid[' | ||
| + | ~~~ | ||
| + | |||
| + | Voir | ||
| + | * cloudant | ||
| + | * cloudant-python-sdk | ||
| + | |||
| + | ~~~bash | ||
| + | pip install --upgrade " | ||
| + | ~~~ | ||
| + | |||
| + | ## Outils tiers | ||
| + | |||
| + | ### CouchBackup | ||
| + | |||
| + | Source : https:// | ||
| + | |||
| + | The couchbackup utility is a command-line tool that allows a Cloudant database to be turned a text file. | ||
| + | |||
| + | Turn our " | ||
| + | ~~~bash | ||
| + | couchbackup --db animals > animals.txt | ||
| + | ~~~ | ||
| + | |||
| + | It comes with a matching utility which does the reverse: restores a text file back to a Cloudant database. | ||
| + | |||
| + | Restore our animals backup to a new database | ||
| + | ~~~bash | ||
| + | cat animals.txt | couchrestore --db animals2 | ||
| + | ~~~ | ||
| + | |||
| + | All we need to do is trigger couchbackup periodically to perform a backup. | ||
| + | |||
| + | |||
| + | |||
