mindcrackx / furniture_mover

Program for easy export and import of a couchdb_database to and from files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Furniture_Mover

Program for easy export and import of a couchdb_database to and from files.

export

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

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.

export_from_all_docs_file

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

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": [
            "^.*$"
        ]
    }
]

Infos:

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

Testing:

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

Dev:

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

About

Program for easy export and import of a couchdb_database to and from files.

License:MIT License


Languages

Language:Python 100.0%