Skip to content
← Back to Community
Db issue
Profile icon
GorgonsLair

Currently I have some keys in my Database that have names like discord users so person#2412 but I'm having trouble deleting the keys. I believe it's because of the '#' but I haven't been able to find a workaround.
When I do:
del db["person#2412"] I get KeyError. Even when I pass it in as a variable, it throws a KeyError. I'm not super familiar with DBs so if I'm doing something wrong here I'd love some feedback.

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
Profile icon
GorgonsLair
Comments
hotnewtop
Profile icon
Coder100

Keys cannot have special symbols inside of them.

The # is one of them.

Unfortunately, there is nothing you can do about that, it won't even be deletable. so next time make sure to serialize the key.

The only solution is to fork the project to clear the db.

Profile icon
GorgonsLair

@Coder100 yeah I forgot to parse that out so I guess I was too late. Thanks for the help!

Profile icon
Coder100

np!
good luck on your db @GorgonsLair

Profile icon
GorgonsLair

@Coder100 I don't know if this is the right repl etiquette, but I know you're good with db's.
I'm trying to update the db using the method below. I've also tried the update() function but my key doesn't change. Is there something I am doing wrong?

db['test'] = { 'some' : 0, 'random' : 0, 'tests' : 0, 'here' : 0 } print(db["test"]) db['test']['some'] = 3 print(db["test"])
Profile icon
KarioTheCoder

Hi @GorgonsLair
It is recommended to save users in the ReplitDB with their user IDs instead of tags as tags can be changed but UIDs can't.