Questions tagged [shelve]

Shelve can refer to either a Python object persistence or a pending change in a Visual Studio Workspace

A shelf in Python is a persistent, dictionary-like object. Documentation: shelve

Shelve can also refer to a pending change in the workspace within Visual Studio 2005

351 questions
2
votes
1 answer

How can I recreate 'dir' for shelve db

Everyday I store data to one shelve file . Today I discovered some last keys missing. The dat-file size is not changed. The dir file and the bak file contains all keys except some last keys. How can I recreate this files, or how can I rescan my dat…
NCNecros
  • 2,395
  • 3
  • 16
  • 20
2
votes
0 answers

Got gdbm error: (13, 'Permission denied') — Despite posix permissions seeming OK

I'm working with shelve in python 2.7.6 for caching calculations, and I've ran into the issue described HERE for shelve files produced by me and implemented the suggested solution in a function that merges a file other into the file target: ... #…
cnaak
  • 994
  • 9
  • 11
2
votes
2 answers

What is the cleanest way to remove data in a shelve?

I have got some datas remaining when I delete an element in a shelve. I tried with pop, del and clear but the result is the same. Datas remaining are in file with the dat extension. So, even after using the method clear the size of the dat file…
Morgan
  • 589
  • 9
  • 20
2
votes
0 answers

In Python 3, how to append a nested dictionary to a shelve file with the added difficulty of using a for loop?

I am trying to figure out how to populate a shelve file with a nested dictionary. These are my requirements: Create shelve file called people.db Append the shelve file with new people (person_1, person_2, etc.). Use a for loop to iterate through…
2
votes
0 answers

Remove an attribute from shelve

I recently started using the shelve module when I needed to save a lot of variables that constantly changed each time the script was ran. Sadly, I'm very inexperience with python in general, and even less so with how shelve works. I removed a…
Lentro
  • 45
  • 5
2
votes
2 answers

Shelve set kind of scenario in Git

My requirement is to do daily checking into local repositories and push them to central repository to avoid code loss due to local system failure. However, I cannot push the code to the actual development branch on origin and need a solution where…
jazz199
  • 911
  • 1
  • 8
  • 12
2
votes
1 answer

Appending a value to a key in Python?

if savescores == "y": name = raw_input("Enter your name.") datfile = filename[0:-4] + ".dat" highscores = shelve.open(datfile) try: highscores[name].append(score) except: …
user4630914
2
votes
0 answers

The shelve module in Python2.7.5 create different database file

I want to create database by shelve module in Python2.7.5 . But, the shelve module create different database file on my two Environment. case of MacBookAir import shelve shelve.open("todo") # -> create 'todo.db' case of Windows7 import…
Alice1017
  • 21
  • 1
2
votes
1 answer

fastest way to check if a key exist in shelve

I have used python shelve library to pre-store a list of key-vector pairs. There are 3 million entries in total, which takes 6 GB memory storage. On a separate training file, I need to check for every record if it is a key in the shelve dictionary.…
Jack Cheng
  • 121
  • 1
  • 11
2
votes
2 answers

Does Python's shelve module use memory-mapped IO?

Does anyone know if Python's shelve module uses memory-mapped IO? Maybe that question is a bit misleading. I realize that shelve uses an underlying dbm-style module to do its dirty work. What are the chances that the underlying module uses…
Matt Luongo
  • 14,371
  • 6
  • 53
  • 64
2
votes
2 answers

shelve gives strange error

I'm trying to put some sites i crawled into a shelve, but the shelve won't accept any Site-objects. It will accept lists, strings, tuples, what have you, but as soon as i put in a Site-object, it crashes when i try to get the contents of the…
thepandaatemyface
  • 5,034
  • 6
  • 25
  • 30
2
votes
1 answer

Move files from all pending (shelved) changelists to a new changelist

In perforce, I have several shelved changelists. I want to move the files from all of these shelved changelists to a new changelist. I can do this with p4 reopen -c [new changelist no.] [file 1, file 2, etc], but it's laborious to copy and paste…
Max Wallace
  • 3,609
  • 31
  • 42
2
votes
2 answers

Python shelve OutOfMemory error

I have some data stored in a DB that I want to process. DB access is painfully slow, so I decided to load all data in a dictionary before any processing. However, due to the huge size of the data stored, I get an out of memory error (I see more than…
fsm
  • 407
  • 2
  • 7
  • 19
2
votes
2 answers

How to deepcopy shelve objects in Python

Is it possible to deepcopy a shelve object in Python? When I try to deepcopy it, I get the following error: import shelve,copy input = shelve.open("test.dict", writeback=True) input.update({"key1": 1, "key2": 2}) newinput = copy.deepcopy(input) >>…
2
votes
1 answer

Shelve: Can't pickle : attribute lookup builtins.method failed

I'm using shelve to store some data. Traceback (most recent call last): File "rogue.py", line 312, in curses.wrapper(game) File "/usr/lib/python3.3/curses/__init__.py", line 94, in wrapper return func(stdscr, *args, **kwds) File…
GGalizzi
  • 813
  • 1
  • 10
  • 18