shelve file name extention

M

Monu

Hi All,
When I am using shelve on my local machine it generates the db file as
given filename. But in another machine it's generating <filename>.dat
and .dir.
can anyone tell me how can I force sheve module to write the db in
<filename>.dir and <filename>.dat, instead of <filename>? Do I have to
install a specific version of the python?

Thanks...
Monu
 
S

skip

Monu> When I am using shelve on my local machine it generates the db
Monu> file as given filename. But in another machine it's generating
Monu> <filename>.dat and .dir. can anyone tell me how can I force sheve
Monu> module to write the db in <filename>.dir and <filename>.dat,
Monu> instead of <filename>? Do I have to install a specific version of
Monu> the python?

Shelve is just a thin layer on top of a concrete db file module. Sounds
like on your two machines there are different underlying db file modules
available. You're pretty much at the mercy of those modules as to file
naming. All you are giving it when opening a shelve file is the prefix.

Skip
 
M

Monu

    Monu> When I am using shelve on my local machine it generates the db
    Monu> file as given filename. But in another machine it's generating
    Monu> <filename>.dat and .dir.  can anyone tell me how can I force sheve
    Monu> module to write the db in <filename>.dir and <filename>.dat,
    Monu> instead of <filename>? Do I have to install a specific version of
    Monu> the python?

Shelve is just a thin layer on top of a concrete db file module.  Sounds
like on your two machines there are different underlying db file modules
available.  You're pretty much at the mercy of those modules as to file
naming.  All you are giving it when opening a shelve file is the prefix..

Skip

Thanks Skip.
So Can't I choose which module to use. Is there any preferance on
which shelve chooses these modules?
 
M

Monu

    Monu> When I am using shelve on my local machine it generates the db
    Monu> file as given filename. But in another machine it's generating
    Monu> <filename>.dat and .dir.  can anyone tell me how can I force sheve
    Monu> module to write the db in <filename>.dir and <filename>.dat,
    Monu> instead of <filename>? Do I have to install a specific version of
    Monu> the python?

Shelve is just a thin layer on top of a concrete db file module.  Sounds
like on your two machines there are different underlying db file modules
available.  You're pretty much at the mercy of those modules as to file
naming.  All you are giving it when opening a shelve file is the prefix..

Skip

Thanks Skip.
So Can't I choose which module to use. Is there any preferance on
which shelve chooses these modules?
 
F

Fredrik Lundh

Monu said:
So Can't I choose which module to use. Is there any preferance on
which shelve chooses these modules?

it uses the anydbm module to look for available DBM-style drivers, which
looks for modules in the following order: dbhash, gdbm, dbm, dumbdbm.

if you know which one you want, you can open the database file yourself,
and pass it to the Shelf constructor:

import shelve
import somedbm

db = shelve.Shelf(somedbm.open(file, flag))

</F>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,740
Latest member
AdolphBig6

Latest Threads

Top