Code Monkey home page Code Monkey logo

Comments (3)

jplana avatar jplana commented on July 24, 2024

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.

Gourds avatar Gourds commented on July 24, 2024

@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.

saurabhsinghmaurya avatar saurabhsinghmaurya commented on July 24, 2024

Same question here
how to create empty directory?

from python-etcd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.