Search code examples
pythondatabaseserializationpersistenceshelve

Shelve: choice of database


shelve documentation says:

The choice of which database package will be used (such as dbm, gdbm or bsddb) depends on which interface is available.

What is that mean? How to determine which package choosen? How to strictly define which one must be choosed? What database implementation best to use?


Solution

  • Found it here:
    http://www.gossamer-threads.com/lists/python/python/13891

    import shelve 
    import gdbm 
    
    def gdbm_shelve(filename, flag="c"): 
        return shelve.Shelf(gdbm.open(filename, flag)) 
    
    db = gdbm_shelve("dbfile") 
    

    ps
    In linked page someone also found this somewhere, but his link is dead.