DBM Samples¶
Creating Data File¶
import dbm.dumb
with dbm.dumb.open("sampledbm", "c") as db:
db[b"Hi"] = b"Hello"
db[b"Bye"] = b"Goodbye"
Template File¶
.. -*- mode: rst -*-
Static Heading
--------------
Individual Item
~~~~~~~~~~~~~~~
- With decoding {{ data['Hi'].decode('ascii') }}
- Without decoding {{ data['Hi'] }}
List of Items
~~~~~~~~~~~~~
{% for item in data.items() %}
- {{item[0]}} -> {{item[1]}}
{% endfor %}
Loading the Template¶
.. datatemplate:dbm:: sampledbm
:template: dbm-sample.tmpl
Rendered Output¶
Static Heading¶
Individual Item¶
With decoding Hello
Without decoding b’Hello’
List of Items¶
b’Hi’ -> b’Hello’
b’Bye’ -> b’Goodbye’