Replit DB raises KeyError for a key that exists

In my script, when I try to get the value of a certain key in my database, I receive a KeyError no matter what the key is. I’ve been having this problem on multiple Repls, the link is below.

Repl link:

db['http://replit.com'] = ""
print(db["http://replit.com"])

This script returns this:

Traceback (most recent call last):
  File "main.py", line 140, in <module>
    db['http://replit.com']
  File "/home/runner/pysearch/venv/lib/python3.8/site-packages/replit/database/database.py", line 439, in __getitem__
    raw_val = self.get_raw(key)
  File "/home/runner/pysearch/venv/lib/python3.8/site-packages/replit/database/database.py", line 479, in get_raw
    raise KeyError(key)
KeyError: 'http://replit.com'

Please help, thanks!

This is a slight limitation of the implementation of ReplDB, keys are just endpoints to the database url. This means you can’t access keys with /s in them. I’d suggest URL encoding your keys.

3 Likes

Alright, thank you so much!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.