difference b/t dictionary{} and anydbm - they seem the same

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • davidj411

    difference b/t dictionary{} and anydbm - they seem the same

    anydbm and dictionary{} seem like they both have a single key and key
    value.
    Can't you put more information into a DBM file or link tables? I just
    don't see the benefit except for the persistent storage.

    d= dbm.open('c:\\t emp\\mydb.dat', 'n')

    It has the following interface (key and data are strings):

    d[key] = data # store data at key (may override data at
    # existing key)
    data = d[key] # retrieve data at key (raise KeyError if no
    # such key)
    del d[key] # delete data stored at key (raises KeyError
    # if no such key)
    flag = key in d # true if the key exists
    list = d.keys() # return a list of all existing keys (slow!)
  • Carsten Haese

    #2
    Re: difference b/t dictionary{} and anydbm - they seem the same

    On Tue, 2008-03-11 at 06:49 -0700, davidj411 wrote:
    anydbm and dictionary{} seem like they both have a single key and key
    value.
    Can't you put more information into a DBM file or link tables? I just
    don't see the benefit except for the persistent storage.
    Persistent storage /is/ the benefit. If you want to store relational
    data, you should use a relational database.

    --
    Carsten Haese



    Comment

    • Robert Bossy

      #3
      Re: difference b/t dictionary{} and anydbm - they seem the same

      davidj411 wrote:
      anydbm and dictionary{} seem like they both have a single key and key
      value.
      Can't you put more information into a DBM file or link tables? I just
      don't see the benefit except for the persistent storage.
      Except for the persistent storage, that insignificant feature... ;) Well
      I guess that persistent storage must be the reason some people use
      anydbm sometimes.

      If you want keys and values of any type (not just strings) and
      persistent storage, you can use builtin dicts then pickle them.

      Cheers,
      RB

      Comment

      • davidj411

        #4
        Re: difference b/t dictionary{} and anydbm - they seem the same

        Persistent storage /is/ the benefit. If you want to store relational
        data, you should use a relational database.
        Thanks, that makes sense. Are there any local relational databases
        available to python that don't require a server backend?

        Comment

        • Joe Riopel

          #5
          Re: difference b/t dictionary{} and anydbm - they seem the same

          On Tue, Mar 11, 2008 at 10:58 AM, davidj411 <davidj411@gmai l.comwrote:
          Thanks, that makes sense. Are there any local relational databases
          available to python that don't require a server backend?
          sqlite

          Comment

          • castironpi@gmail.com

            #6
            Re: difference b/t dictionary{} and anydbm - they seem the same

             Thanks, that makes sense. Are there any local relational databases
             available to python that don't require a server backend?
            >
            sqlite
            http://www.sqlite.org/
            Are there any that aren't persistent?

            Comment

            • castironpi@gmail.com

              #7
              Re: difference b/t dictionary{} and anydbm - they seem the same

              Are there any that aren't persistent?
              >
                      SQLite -- when opening a "memory" database rather than giving it a
              physical file. {I'm a tad too busy to look up the format of the memory
              parameter, but it shouldn't be too difficult to find it}
              What? If I wanted to code string literals, I'd use exec. Where's the
              real one?

              Comment

              Working...