A thin wrapper around Python Module etcd3 to make life a little bit easier https://pypi.org/project/etcd3/
Find a file
2019-09-12 18:51:18 +05:00
etcd3_wrapper correct import 2019-09-12 18:51:18 +05:00
.gitignore cleaning and preparing for pypi 2019-09-11 16:31:02 +05:00
LICENSE LICENSE added 2019-09-11 16:32:04 +05:00
Pipfile Pipfile added 2019-09-12 14:01:11 +05:00
Pipfile.lock Pipfile added 2019-09-12 14:01:11 +05:00
README.md cleaning and preparing for pypi 2019-09-11 16:31:02 +05:00
setup.py correct import 2019-09-12 18:51:18 +05:00

etcd3_wrapper

A thin wrapper around Python module etcd3 to make it a little easier to deal with etcd.

Warning: The API isn't fully stable and can changed significantly in future.

For Example, you want to get an entry from etcd. You would write something like this

from etcd3_wrapper import Etcd3Wrapper

client = Etcd3Wrapper()
entry = client.get("/planet/earth")

if entry:
    # It would print key and value of entry
    # in bytes format b'....'
    print(entry.key, entry.value)

Output

b'/planet/earth' b'{"population": "7.53 Billion"}'
# If you know that the value in etcd is in JSON
# format. You can do the following

json_entry = client.get("/planet/earth", value_in_json=True)

if json_entry:
    # Now, entry.value is of type dict
    print(entry.key, entry.value)

    # So, you can do this too
    print(f"Earth population is {entry.value['population']}")

Output

/planet/earth {"population": "7.53 Billion"}
Earth population is 7.53 Billion