del db["https://google.com"]
gives this error code below:
Traceback (most recent cal last):
File "main.py", line 53, in <module>
del db["https://google.com"]
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/replit/database/database.py", line 540, in __delitem__ raise KeyError(key)
KeyError: 'https://google.com'
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.
Basically replit db deletes by sending url requests to a https://kv.replit.com/v0/... url by sending it via url key like this (code snippet from source code):
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 = "https://google.com"
# url2 = "https://replit.com"
db["urls"] = []
db["urls"].append(url)
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.