Ask coding questions

← Back to all posts
[Python] DB -- variables not updating when program is run again
Bookie0 (5947)


This is a typing speed program where you can measure how fast you type and get your WPM, accuracy, as well as your average accuracy, highest WPM, etc. I'm looking to save these using DB, so I use those variables.

However, I have to define those variables, so I set them to 0.

But each time I run the repl, it sets those variables back to 0 which changes the data in the DB.

Could anyone help? When you run the repl, create an account, then press tab to start a test. Note your average WPM, average accuracy, and highest WPM:

Then try to run the repl again. Since the variables are reset back to 0 (lines 152), it resets the variables in the DB as well. So if you do a slower WPM on the second time, it will still use that WPM as the highest, even if you had a higher one on the first try.

Around line 678 is when I add those variables in the DB.

Any help is gladly appreciated! I've tried to add comments to make the code easier, but it may sometimes be messy.

If you need further explanation or want to invited to a repl, pls lmk. My discord is Bookie0#7538 if it makes it easier.

Thank you so much!

Open repl pls and slide console to see the stuff thanks

Dart (1185)

Try minxes easypydb instead, it works pretty much the same way, and there is no key limit as far as I can tell :)

Bookie0 (5947)

@Dart but this isn't really related to key limit..? I'm pretty sure this isn't a problem with DB but with my code.. :)

Dart (1185)

@Bookie0 lol no, besides from your code being slightly inefficient it’s most likely a problem with repl db trust me. Im just saying you should switch dbs. Also don’t store json with repl db that’s a terrible idea.

Bookie0 (5947)

@Dart yea it is kinda inefficient at certain parts.

but what would repl db have to do with the problem? Isn't it not working well because of the variables being defined?

and wait what's wrong with json for repl db?

IntellectualGuy (658)

This seems to be a problem with replit db, I don't think it's your code. I had the same problem maybe use another database, such as Mongodb

Bookie0 (5947)

@IntellectualGuy nono, I think it's something to do with me, I know what the problem is (variables being re-defined) but Idk how to solve it