Comments (3)
Hi!
Yes, you can create new directories with the library (using master) and etcd 0.2.rc1 :
>>> import etcd
>>> client = etcd.Client()
# This will create the directory "directory" and set the key "key" with value "1"
>>> client.write('/nodes/directory/key', 1)
# You can now retrieve all keys within that directory using
>>> client.read('/nodes/directory')
EtcdResult(action=u'get', key=u'/nodes/directory', value=None, expiration=None, ttl=None, modifiedIndex=3, prevValue=None, newKey=False, dir=True, kvs=[EtcdResult(action=None, key=u'/nodes/directory/key', value=u'1', expiration=None, ttl=None, modifiedIndex=3, prevValue=None, newKey=False, dir=False, kvs=None)])
# Or something like
>>> [v.value for v in client.read('/nodes/directory').kvs]
[u'1']
If you're using our latest released version from pypi (0.2.1) and etcd version v0.1.2 you can:
>>> import etcd
>>> client = etcd.Client()
# This will create the directory "directory" and set the key "key" with value "1"
>>> client.set('/nodes/directory/key', 1)
# You can now retrieve all keys within that directory using
>>> client.get('/nodes/directory')
[EtcdResult(action=u'GET', index=3, key=u'/nodes/directory/key', prevValue=None, value=u'1', expiration=None, ttl=None, newKey=None, dir=False)]
# Or something like
>>> [v.value for v in client.get('/nodes/directory')]
[u'1']
from python-etcd.
@jplana In addition to the following method, Is there have any more direct way?
client.set('/nodes/directory/key', 1)
Because I just want to create an empty directory
from python-etcd.
Same question here
how to create empty directory?
from python-etcd.
Related Issues (20)
- lock.aquire fall into infinite loop HOT 2
- There should be a way to prevent python-etcd from appending a slash to key names
- Lock object seems to not provide locking
- Unable to write or read HOT 1
- I can not use ca connect my etcd
- Stale connection
- Just created key can be omitted HOT 1
- how to client a cluster?
- Make a 0.4.6 release HOT 4
- locks with ttls are broken
- EtcdWatchTimedOut does not been raised when occur
- How to pass private SSL key HOT 1
- Make default port 2379
- WIP: porting the package out of the nose dependency
- incompatible version of dnspython HOT 1
- SRV srv_domain parameter is ignored HOT 5
- Cannot import etcd even I have installed python-etcd on my computer. HOT 1
- Does this client support ETCD v3 servers? HOT 1
- Still maintained? HOT 1
- Fix handling of etcd clusters with self-signed certificates
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-etcd.