Replit Database (using python)

there is obviously a lot more code but the piece of code below is what I’m having trouble with.

url = ""

db[url] = ""

# above creates a key in my replit database
# key name: ""
# key value: ""

but when i do:

del db[""]

it doesn’t work and I’ve tried googling and looking at forums here but gotten no answer that solves my problem.

if you know about how to do this please help.

del db[""]
gives this error code below:

Traceback (most recent cal last):
File "", line 53, in <module>
del db[""]
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/replit/database/", line 540, in __delitem__ raise KeyError(key)

KeyError: ''

Welcome to the community, @Kaleb1583!

That’s an interesting bug. Can you go to ToolsDatabase and check that the keys are actually being saved?

I have given it a try and from what I have seen, when the symbol / or // is used, the key/pair is created but it throws an error when trying to read it.
Looks like a bug and I would say in the meantime just replace the symbol with something else and put the symbol back when needed.

Really weird.

1 Like

Basically replit db deletes by sending url requests to a url by sending it via url key like this (code snippet from source code):

self.sess.delete(self.db_url + "/" + urllib.parse.quote(key))

I believe it is not “proper” url protocol to put '//` in it or something so basically that’s why it works for getting/setting but not deleting (replit db doesn’t do this for get/set, only for deleting for some reason).


Getting also does nit seem to work. It only works for setting.
I understanding if the issue would come with \\ as backslash is a special character, but normal slash should be ok.


Welcome to the community @Kaleb1583 , If you’re only saving URL’s to a DB maybe try this code below:

from replit import db
import time

url = ""
# url2 = "" 

db["urls"] = []

time.sleep(2) # wait before deleting url
del db["urls"][0] # indicating first val

In this code, im just appending the url to an already existing value then deleting it.