Git init
[pkgs/e/elektra.git] / src / bindings / python / cascading.py
1 #!/usr/bin/python
2
3 # try: 
4 # > kdb set user/myapp "hello world!"
5 # > kdb set system/myapp "hi world!"
6 # > python cascading.py
7
8 from libelektra import *
9 import sys
10
11 def BailOut(msg):
12         print 'msg'
13         print kdbStrError(kdbhGetError(0))
14         sys.exit(1)
15
16 ks=ksNew()
17
18 (h,r)=kdbOpen()
19 if r==-1:
20         BailOut('Could not open key database')
21
22 if kdbGetChildKeys(h,"user/myapp",ks,0)==-1:
23         BailOut('Could not get keys')
24
25 if kdbGetChildKeys(h,"system/myapp",ks,0)==-1:
26         BailOut('Could not get keys')
27
28 k=ksLookupByName(ks,"/myapp/key",0);
29 if k==0:
30         BailOut('Could not lookup keys')
31
32 print keyStealValue(k)
33 ksDel(ks)
34 kdbClose(h)