Ask coding questions

← Back to all posts
Deleting Items with 'Illegal chars' in repl.it db
ENIAC1

I can't seem to figure out how to delete items with illegal characters in them as the db throws the error;
"KeyError: {db_key}" wherein db_key is the key with chars creating the problem (ie. '/*123asd').

Attempted Solutions

  • For loop
    for x in db.keys(): del db[str(x)]
    &&
    for x in db: del db[str(x)]
    &&
    for index, key in enumerate(db): db.pop(index)
  • db.clear()
    db.clear()

Things to know about repl.it db:
type(db) = <class 'replit.database.database.Database'> != array||list

Question was asked in these places as well with no answer that currently works (at least with my current db):
https://replit.com/talk/ask/How-do-I-clear-all-data-from-my-repl-database/53973
https://replit.com/talk/ask/Is-there-a-way-to-delete-everything-from-a-replit-database/59161

[email protected]

Voters
ENIAC1
Comments
hotnewtop
CodingElf66

Just do:

Hope this helps!

ENIAC1
CodingElf66

@ENIAC1 Then idk. If you want to output them, then if it has the key, then don't output it. That's my suggestion.