Adding Entries to a DBM File : DBM « Database « Python Tutorial






import anydbm

cities = ["Dallas", "Los Angeles", "New York"]
flights = ["1144", "1045", "1520"]
times = ["230pm", "320pm", "420pm"]

cityDB = anydbm.open("city.dbm", 'n')
timeDB = anydbm.open("time.dbm", 'n')

i = 0
for flight in flights:
    cityDB[flight] = cities[i]
    i += 1
i = 0
for flight in flights:
    timeDB[flight] = times[i]
    i += 1

print cityDB.items()
print timeDB.items()

cityDB.close()
timeDB.close()








15.2.DBM
15.2.1.Adding Entries to a DBM File
15.2.2.Retrieving Entries from a DBM File