I’ve made a database to store URLs and titles of various posts, with the URL being the key. Unfortunately I now can’t access any of the keys since they are URLs (according to this post: Replit DB raises KeyError for a key that exists).
My typical way of emptying the db is:
for key in db.keys():
del db[key]
This returns a KeyError.
Is there any way to clear the database in python without calling on keys, or is my only option to fork it?
I just realized how ridiculous this sounds, replit nuke sounds a lot more like destroying your Repl than simply clearing your database, but that’s just me
A keyerror indicates that the program tried to access an item in the db that does not exist. For example, if you tried to access db["nonExistentUser"] when nonExistententUser doesn’t exist yet, then you would get KeyError: nonExistendUser. In your case, the program found an item that was called https://ask.replit.com/t/getting-captcha-in-100daysofcode-90th-day/54400, but then the program also couldn’t access that item. In this case, i would enter the python console, and run the following code:
from replit import db
print(db.keys())
and share the output with us (as long as it doesn’t contain any confidential information)
Thanks for the response! Unfortunately I just forked and deleted the original repl. The keys I was using were definitely in the DB since to get them I was using:
for key in db.keys():
del db[key]
I think it’s because they were a url and that causes problems apparently. Going to re-make it but using a different key.