Changing Objects in a Shelve File : Shelve : Database PYTHON TUTORIALS


PYTHON TUTORIALS » Database » Shelve »

 

Changing Objects in a Shelve File


import shelve

newtimes = ["110pm""220pm""300pm""445pm"]

db = shelve.open("shelved.dat""w", writeback=1)

for k in db.keys():
    obj = db[k]
    print "%s: %s" (k, obj)

flights = db['flights']
times = db['times']

flights['1145'] "Dallas"
flights['1709'] "Orlando"

db['times'] = newtimes

db['oldtimes'] = times

db.sync()

for k in db.keys():
    obj = db[k]
    print "%s: %s" (k, obj)

db.close()



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Database
» Shelve