https://github.com/ae-foster/rdbgenerate
Utility for generating Redis dump (.rdb) files from Python native objects
https://github.com/ae-foster/rdbgenerate
databases encoding rdb redis
Last synced: 3 months ago
JSON representation
Utility for generating Redis dump (.rdb) files from Python native objects
- Host: GitHub
- URL: https://github.com/ae-foster/rdbgenerate
- Owner: ae-foster
- License: gpl-3.0
- Created: 2017-07-22T17:38:10.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2025-05-23T07:35:43.000Z (about 1 year ago)
- Last Synced: 2025-10-01T04:48:15.314Z (9 months ago)
- Topics: databases, encoding, rdb, redis
- Language: Python
- Size: 24.4 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# rdbgenerate
Utility for generating Redis dump (.rdb) files from Python native objects
## Installation
You can install this package using `pip`
pip install rdbgenerate
## Version support
`rdbgenerate` is written for Python 3.
## Generated `.rdb` files
The `.rdb` files generated by `rdbgenerate`:
- do not use compression to reduce size, unlike Redis itself which uses
smart encoding formats to keep file size down
- do not include auxiliary information such as database size hints,
additional version information, etc.
## Usage
Once installed, use `rdb_generate` to write `.rdb` files.
$ python
>>> from rdbgenerate import rdb_generate
>>> rdb_generate(
'dump.rdb',
db0={
b"a": b"0",
b"b": {b"1"},
b"c": [b"1", b"2", b"3"],
b"d": {b"x": b"y"}
},
db1={
b"California": b"dreamin'"
}
)
>>> quit()
$ redis-server
### Encodings
This package supports strings that are Python `bytes` objects. It does *not* support regular Python strings.
Python strings can be converted to `bytes` via
>>> s = "California"
>>> b = s.encode('utf8')
>>> print(b)
b"California"
For more information on string encoding in Python 3, see https://docs.python.org/3/howto/unicode.html .