Hallo,
hat wer Beispiele, oder eine Dokumentation für das Datenbankformat tdb?
Python Bindings gibt es ja dafür.
Danke.
lg Richi
Python Dokumentation für den Zugriff auf TDB
Meinst Du das interne Format eine tdb-Datei oder nur die Semantik, wie mit einer solchen Datei umgegeangen werden kann? Für die zweite Frage gibt es tdbtool, das z. B. für Ubuntu aus dem Pakete tdb-tools installiert werden kann. Eine Verwendung dieses Tools könnte so aussehen.
Die Python-Bindings funktioniere dann ähnlich.
Code: Alles auswählen
% tdbtool
tdb> create foo.tdb
tdb> insert k1 42
tdb> insert k2 "Some text"
tdb> insert k3 "more text"
tdb> keys
key 2 bytes: k3
key 2 bytes: k1
key 2 bytes: k2
tdb> show k2
key 2 bytes
k2
data 11 bytes
[000] 22 53 6F 6D 65 20 74 65 78 74 22 "Some te xt"
tdb> dump
key 2 bytes
k3
data 11 bytes
[000] 22 6D 6F 72 65 20 74 65 78 74 22 "more te xt"
key 2 bytes
k1
data 2 bytes
[000] 34 32 42
key 2 bytes
k2
data 11 bytes
[000] 22 53 6F 6D 65 20 74 65 78 74 22 "Some te xt"
Code: Alles auswählen
In [1]: import tdb
In [2]: t = tdb.Tdb("foo.tdb")
In [3]: t.keys()
Out[3]: ['k3', 'k1', 'k2']
In [4]: t["k2"]
Out[4]: '"Some text"'
In [5]: t.items()
Out[5]: [('k3', '"more text"'), ('k1', '42'), ('k2', '"Some text"')]
In [6]: t["k4"] = "23"
In [6]: t.close()
Out [6]: 0