Program for easy export and import of a couchdb_database to and from files.
Export a couch with its current documents to a given filepath.
Usage: __main__.py export [OPTIONS] FILEPATH DB
Arguments:
FILEPATH [required]
DB [required]
Options:
--url TEXT [default: http://localhost:5984]
--user TEXT
--password TEXT
--proxy TEXT
--timeout FLOAT [default: 3]
--cert-verify / --no-cert-verify [default: True]
--help Show this message and exit.
Import a couchdb from file which has to be generated by either from export
or from export_from_all_docs_file
.
Uses one request for each revision by using _bulk_docs.
Use --no-same-revision
if the documents should only be imported with revision 1.
Usage: __main__.py import [OPTIONS] FILEPATH DB
Arguments:
FILEPATH [required]
DB [required]
Options:
--url TEXT [default: http://localhost:5984]
--user TEXT
--password TEXT
--proxy TEXT
--timeout FLOAT [default: 3]
--db-exists-ok-if-empty / --no-db-exists-ok-if-empty [default: True]
--same-revision / --no-same-revision [default: True]
--cert-verify / --no-cert-verify [default: True]
--help Show this message and exit.
Generate the same output like export
but use a file instead of a database.
The expected file can be generated by getting couchurl/COUCHDB/_all_docs?include_docs=true
Usage: __main__.py export_from_all_docs_file [OPTIONS] ALL_DOCS_FILEPATH FILEPATH
Arguments:
ALL_DOCS_FILEPATH [required]
FILEPATH [required]
Options:
--help Show this message and exit.
Filter a export-file of a database into multiple files by using a FILTER_FILE.
Usage: __main__.py filter [OPTIONS] FILTER_FILE INFILE
Arguments:
FILTER_FILE [required]
INFILE [required]
Options:
--help Show this message and exit.
If any regex matches the document-Id, it will be put into the specifies output file. Example filter.json:
[
{
"filepath": "out/test_1.txt",
"regex_filters": [
"^TESTDOC_\\d+$",
"^.*?_(test)+$"
]
},
{
"filepath": "out/test_2.txt",
"regex_filters": [
"^.*$"
]
}
]
If no furniture_mover.ini
file lies next to the executable, no logging will be done.
Configure logging by modifying furniture_mover.ini
.
The default logfile-path is furniture_mover.log
.
j
Test against a docker couchdb
docker run -p 5984:5984 -d --name furniture_mover_couchdb -e COUCHDB_USER=admin -e COUCHDB_PASSWORD=adminadmin couchdb
poetry run pytest -v
Install pre-commit-hooks
pre-commit install
Run before commit:
poetry run isort -rc furniture_mover
poetry run isort -rc tests
poetry run black furniture_mover
poetry run black tests
poetry run flake8 furniture_mover
poetry run flake8 tests
poetry run mypy furniture_mover
poetry run mypy tests
poetry run pytest -v