rdbtools3¶
Redis dumps parser and cli tool.
Installation¶
The easiest way to install rdbtools3 is by using the package on PyPi:
pip install rdbtools3
Source code¶
The project is hosted on GitHub and can be installed running following commands:
git clone https://github.com/popravich/rdbtools3.git
cd rdbtools3
python3 setup.py install
# optionally, run tests with
make test
Fill free to fork it and/or to report any found issues/ideas on bug tracker
Getting started¶
The simpliest way to start using tool:
from rdbtools3 import parse_rdb_stream
with open('/path/to/redis/dump.rdb', 'rb') as f:
for item in parse_rdb_stream(f):
print(item.key, item.value)
And on command line:
python3 -m rdbtools3 /path/to/redis/dump.rdb
Indices and tables¶
rdbtools3
— Parser API¶
Parser¶
-
rdbtools3.
parse_rdb_stream
(f, skip_db=lambda dbnum: False, skip_key_type=lambda dbnum, key_type: False, skip_key=lambda dbnum, key_type, key: False)¶ Parameters: - f (file) – File stream
- skip_db (function) – callback to check if db should be skipped.
- skip_key_type (function) – callback to check if key type should be skipped.
- skip_key (function) – callback to check if key should be skipped.
Returns: generator that yields
RDBItem
‘sReturn type: generator
Raises: - rdbtools3.FileFormatError – if read invalid magic string, unsupported RDB version or no “select db” code found.
- rdbtools3.RDBValueError – if parser encounters unexpected data value.
Parses Redis dump file stream.
RDBItem¶
-
class
rdbtools3.
RDBItem
(dbnum, key_type, key, value, expire, info)¶ Parameters: Named tuple representing Redis DB item.
Exceptions¶
-
exception
rdbtools3.
ParserError
¶ Base parser exception type.
Subclass of
ValueError
.
-
exception
rdbtools3.
FileFormatError
(msg)¶ Raised if magic string is invalid, RDB version number invalid or not supported or no “select db” control code found.
-
exception
rdbtools3.
RDBValueError
(msg)¶ Raised if unexpected value received.
rdbtools3.cli
— Command-line interface (cli)¶
Note
CLI is still being developed so documentation yet to come.
You can always get help running python3 -m rdbtools3.cli –help