Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
21 views

I am confused with the way execution is supposed to take place. I do not understand why the code is not executed. I am using shelve [duplicate]

This is a code segment that begins line 261 in my file. if __name__ == '__main__': # main() print('Checkpoint 0') createShelve() print('Checkpoint 1') data = loadShelve() print('Checkpoint ...
Alphonsus's user avatar
5 votes
2 answers
68 views

Does shelve write to disk on every change?

I wish to use shelve in an asyncio program and I fear that every change will cause the main event loop to stall. While I don't mind the occasional slowdown of the pickling operation, the disk writes ...
Bharel's user avatar
  • 26.1k
0 votes
0 answers
22 views

How to Recover the .idea Folder in an Android Project?

I mistakenly deleted the .idea folder in my Android project through the Android Studio Git commit section under ignored files. Unfortunately, the folder did not go to the recycle bin. The .idea folder ...
di1um's user avatar
  • 41
0 votes
0 answers
40 views

Problem using `shelve` in "__main__" vs imported module

Consider the following program (Python 3.10), which consists of two files: mymodule.py import dataclasses import shelve from typing import Optional # public api # ---------- @dataclasses.dataclass ...
Jason C's user avatar
  • 40k
0 votes
0 answers
25 views

Does python shelve module allocate space in chunks of a certain size?

I stored some pandas dataframes in a shelve and then stored the same dataframes but potentially containing a bit more data (maybe a few % more). The second shelve is about twice the size of the first ...
s5s's user avatar
  • 12k
0 votes
0 answers
65 views

Get back unseen shelf changes

I have a problem of shelve changes being lost. I was modyfying the project so much, that the history of shelve changes got exceeded in IntelliJ panel. (panel I mean second picture from: https://www....
tomeklfc's user avatar
0 votes
0 answers
18 views

I am using shelvedb in docker. but when i am writing or updating my DB it's now happening

ShelveDB is not updating in the docker. I am using multiple thread in my code and also i am not closing my shelveDB because of i can't close DB. I have to update my DB after every 5 second. i am ...
Vinayak Nagar's user avatar
0 votes
1 answer
20 views

I set db_ID_1 to '0' with shelve module like pickle module.. i print db_ID_1 and it = 0 but when I do... IF db_ID_1 != '0': .. it think it isn't 0

pickle is just like Shelve, I'm using Python 3.10.7 VENV environment on visual studio code it says db_ID_1 is 0 in the terminal but when it comes to.. if db_ID_1 != '0': .. it think it isn't a 0 so ...
MENTORJJ's user avatar
0 votes
0 answers
31 views

Shelve module: How to instantly write on memory when using 'deque.append()'

import shelve from collections import deque with shelve.open('123', writeback=True) as DATA: DATA['TEST'] = deque() DATA['TEST'].append(1) DATA['TEST'].append(2) This code creates a deque ...
Nico Carrión's user avatar
1 vote
2 answers
169 views

How do I access multiple python/shelve database at the same time?

I'm building a simple program that concurrently save data to different shelve database with multithreading but error occurs when 2 threads invoke shelve.open() (for different files): import threading ...
Rahn's user avatar
  • 5,355
0 votes
0 answers
101 views

Is it insane to store access token in shelve object?

My friends and I are making a project to study programming. It consists of several microservices. For our main microservice we use Redis to store auth tokens and it works great. But we needed another ...
Bohdan Kholodenko's user avatar
0 votes
2 answers
298 views

How to migrate `shelve` file from Python 3.10 to Python 3.11

Code: with shelve.open("cache") as db: ... Python 3.10.9 result A cache.db file is created. Python 3.11.1 result Three files are created: cache.cir, cache.bak, cache.dat. What I need I ...
user avatar
0 votes
0 answers
71 views

Shelve is not loading all the keys stored inside the .db file when iterating through the file

I am getting an intermittent error where shelve does not load all the keys stored inside it when I iterate through as shown in the code below. kc was a debug variable to see what was going on--I have ...
Akshay's user avatar
  • 1
1 vote
1 answer
195 views

Python shelve module type hints in PyCharm, "expected type xx, got Shelf[object] instead"

I'm trying to understand why I'm getting IDE warnings about how I'm using the Python shelve module. All of the code here functions fine, I'm just getting IDE (PyCharm 2022.2.3 community edition) type ...
ZombieGreedo's user avatar
0 votes
1 answer
42 views

How do I get stored dictionaries' values from a shelve-file back into the program

I started learning Python 2 weeks ago, and now I am trying to code a text adventure game. However, I've run into a problem. So far, I haven't found any solution on Google which can help me. I decided ...
Mishra's user avatar
  • 3
0 votes
1 answer
36 views

How to share tkinter widget in a shelve store?

Is it possible to share a Tkinter widget using the shelve module? For example: from tkinter import * import shelve tk = Tk() with shelve.open("store") as holder: holder["tk"] = ...
UnArbreSauvage's user avatar
0 votes
1 answer
145 views

How to specify nested type hint for a shelve object?

Trying to use the Python persistence library shelve import shelve cache = shelve.open("path/to/cache") cache["b"] = 3 cache.sync() This works fine. Now I want to specify a type ...
Gulzar's user avatar
  • 27.2k
0 votes
2 answers
291 views

Python shelve module why is this code fast, but the other slow?

The output of the code below is fast: 0.018553733825683594 slow: 7.0305609703063965 and, more than that, the file of slow.dat is 10,252KB while fast.dat is only 32KB. Why is the fast one small.. fast ...
Alex Mortez's user avatar
1 vote
0 answers
422 views

How to add row number while printing

Here's a function I created for challenge 7.2 in Dawson book, but wanted to modify it a little bit. To not spam I'm sending just key place as other is not related to the problem. def results(score): ...
Mr. Chris's user avatar
1 vote
1 answer
327 views

Python Shelf file grows when trying to overwrite data

When I add columns to dataframes stored in a shelf object I am seeing exponential growth in the shelf file size. It is like a complete copy of an entry is created, with the added column applied, every ...
Mat's user avatar
  • 190
2 votes
1 answer
193 views

python shelve is not saving/loading

When I save/load my workspace via functions in a subfile, shelve doesn't work (test1). However, if I do the same in one file, it works (test2). Why is that? How can I fix the problem for the first ...
yufiP's user avatar
  • 113
0 votes
0 answers
62 views

I want to write using the 'shelve' module, but after entering 3 data, I can't enter anymore and the keys in the file are stored incorrectly

I want to write using the 'shelve' module, but after entering 3 data, I can't enter anymore and the keys in the file are stored incorrectly ['3', '1', '2']. that's what happens on linux, and it's all ...
Otabek's user avatar
  • 13
0 votes
1 answer
36 views

I have a piece of code with the output of dictionaries in a text file, and I had a question whether it can be done with the shelve module?

I have this piece of code dict3 = {'12345': ['paper', '3'], '67890': ['pen', '78'], '11223': ['olive', '100'], '33344': ['book', '18']} output = open("output.txt", "a", encoding='...
st040506's user avatar
0 votes
1 answer
511 views

Shelve module: What's the point of 'writeback' variable?

Take a look at the code snippet below Python 3.10.1 (main, Dec 10 2021, 10:36:36) [Clang 12.0.5 (clang-1205.0.22.11)] on darwin Type "help", "copyright", "credits" or &...
anu's user avatar
  • 1,007
0 votes
0 answers
249 views

recover pickled data: pickle data was truncated

Normally, the shelve data should be read and write by only one process at a time, but unfortunately it was simultaneously read and write by two processes, thus corrupted it. Is there any way to ...
iMath's user avatar
  • 2,466
0 votes
1 answer
147 views

Why can't I store in a shelf file a dictionary that stores objects?

I'm using a dictionary to store objects. The dictionary is then stored in a shelf file. When retrieving the dictionary from the shelf file for printing stuff, it gets an error. The following script is ...
zsfzu0's user avatar
  • 154
0 votes
0 answers
74 views

How to clean a Python shelf file?

I have a python shelf file that's roughly 100MB in size. I have a naive function that's supposed to clean the shelf from unneeded entries that looks like this: def cleanShelf(shelf): for key in ...
uzumaki's user avatar
  • 1,913
1 vote
0 answers
41 views

unsure on why i am getting a traceback issue while using shelve

any help would be appreciated! I copied and pasted the code from another application that i made. the issue appears when initiating the login or userregistration functions import shelve import time ...
DawsUTV's user avatar
  • 35
0 votes
0 answers
126 views

Python shelve get() and keys() methods return inconsistent results

I am running code that writes data to shelve (Python 3.6 in conda env). While checking output I noticed that get() method return value for key "5000", yet methods keys() and items() do not ...
Artur Siedlecki's user avatar
0 votes
1 answer
367 views

How to load a CSV into a sqlite DB using csv headers as table columns using python

I have a csv file for all the plane crash incidents since 1908. The csv header columns are, Date,Time,Location,Operator,Flight #,Route,Type,Registration,cn/In,Aboard,Fatalities,Ground,Summary My code ...
foobar666's user avatar
0 votes
0 answers
282 views

Python shelve not saving nested keys

I am using the shelve module to save some Python objects (strings in the example). When I am trying to save an object as a nested key, then it is not being saved. class Car: def __init__(self, ID):...
Prashant Sengar's user avatar
0 votes
0 answers
39 views

Shelve Module considered as shelve.py

enter image description here Hey, i am new in python i am trying to import shelve module but pycharm say Traceback (most recent call last): File "C:\Users\mavic\PycharmProjects\ABS-CH8\shelve.py&...
Avicena's user avatar
0 votes
1 answer
81 views

How to assign subtotal from one function to another function?

I have to set the total_cost variable to be equal to the subtotal variable or the from the product class. However, when I try to derive the value from the class. It gives me an attribute error of ...
Luna's user avatar
  • 21
0 votes
0 answers
71 views

How do i use datetime or time function in Python for a lucky draw section i am doing?

So, currently i kind of make a lucky draw that generates random numbers and assigned it to promo codes (which is lucky draw prize) i want to make sure that a person can do the lucky draw once a day so ...
Luna's user avatar
  • 21
0 votes
2 answers
152 views

How to set value in shelve

I want to store dictionary in shelve and also want to put data in that. How can i do that? import shelve s = shelve.open("test") s['flag'] = {}
Bhavesh Mevada's user avatar
0 votes
1 answer
387 views

Save and load variables using shelve

I'm trying to implement a code that will generate a lot of scenarios. This scenarios will be executed after by a 3 different simulators. I'm saving my scenarios in a file using shelve. My code is like ...
Henrique Lima's user avatar
1 vote
1 answer
615 views

Convert Python shelve from dbm.gnu to dbm.dumb

I am trying to convert data stored in a non-dumb shelve to a dumb shelve, to be able to access my data at a location where the non-dumb libraries are not installed. My test code for transforming the ...
zanzu's user avatar
  • 55
2 votes
0 answers
577 views

Use dbm.ndbm / Berkeley DB to open a serialized Python shelve on a machine where only dbm.dumb seems to be installed

I am using a software package which generates serialized Python shelves. On the remote machine where the shelves are generated, I can open them and process them perfectly. However, when I copy them on ...
zanzu's user avatar
  • 55
-2 votes
1 answer
38 views

How to keep and run the program always form the last value, so when I open again the program starts from the last amount

import random amount = 100 loggedOn = True while loggedOn: selection = int(input("Select 1 for Deposit, 2 for Withdraw or 3 for Exit: ")) if not selection: break if ...
wgarcias2020's user avatar
0 votes
1 answer
252 views

How can I exactly delete specific keywords from the command line described as a list? [duplicate]

I am supposed to use the command line argument to save content to keywords or (and here is my issue; delete keywords) Hey I already researched similar questions. However, I do not see why it does not ...
user avatar
1 vote
1 answer
370 views

My TreeView from my GUI app with tkinter doesn't work after I build the app using cx_freeze and executing the .exe file

I've created an app with tkinter to practise which resembles a virtual purse to keep track of your expenditures. You can add deposits and withdrawals of money in different categories, which is all ...
axelsolsona's user avatar
0 votes
1 answer
101 views

EOFError: Ran out of input while trying to store turtle information

I'm trying to make a turtle display that remembers where I've moved an object. For that I'm using the shelve module. The information about the turtle location, and the turtle.Turtle() itself is ...
Bhaskara's user avatar
2 votes
0 answers
86 views

Python shelve leak?

It seems that when overwriting a key in a shelve, under certain circumstances the shelve size unexpectedly keeps growing larger. It is as if some data in a shelve ends up not having a reference to it, ...
rinspy's user avatar
  • 386
0 votes
1 answer
1k views

Multiclipboard Automate the boring Stuff

I have some difficulties to run this program. You can see how to run it on Windows. But how does it work for Mac? For instance, python3 mcb.py save spam, when I type it into the console in Spyder it ...
user avatar
0 votes
1 answer
486 views

How can I check if an item is stored in a shelve database quickly?

I'm working with the shelve library, on Python 3.8.3., and I'm fairly confident with creating new entries from a database, and reading a certain key's values. However, I can't do something like this: ...
J. Dionisio's user avatar
1 vote
1 answer
144 views

shelve does not sync to disk before close

After changing the version of python from 3.5 to 3.7, shelve does no longer write to disk when calling the sync method. However, when I use python 3.5 it does. I also noticed the on python 3.7 a 'db' ...
Morten's user avatar
  • 2,278
0 votes
1 answer
572 views

Pushing local workspace code to TFS server

I am writing automation script for creating local workspace and modify few files in local workspace and finally push the changes to the TFS server and Build the changes using Shelveset build and then ...
Manju's user avatar
  • 21
1 vote
0 answers
50 views

What are 'recursive data types' in Python, as referenced by the shelve doc? [duplicate]

The shelve package doc paragraph below mentions the term ("recursive data types"). What does "recursive data type" mean in Python? What I know is that the word recursive means to return something. ...
jamaal's user avatar
  • 27
1 vote
0 answers
104 views

Why does python shelf module give an error at start up when opening file

I have been using the python shelf module to store face encodings from the python face-recognition module below. I did this to make the live image recognition process faster. I then imported these ...
Vidura's user avatar
  • 11
2 votes
1 answer
970 views

Understanding the sync method from the python shelve library

The python documentation says this about the sync method: Write back all entries in the cache if the shelf was opened with writeback set to True. Also empty the cache and synchronize the ...
ashir's user avatar
  • 111

1
2 3 4 5
8