I wanna add a prefix to a key
but i dont think i know how:
Repl link :
this i what i did two add a prefix
from replit import db
db.one["key"] = "apple"#i added one before the key
db.two["key"] = "orange"#i added two after db
print(db.one["key"])
print(db.two["key"])
this is the error that followed
1 Like
I think no attributes can be added to the replit database!
do you know how to assign a prefix to a key
That’s the thing, you cant.
oh ok
But then what does it mean by this
Interesting, I’ll investigate!
It’s used to list all keys that start with a prefix, for example:
from replit import db
db["key1"] = "value1"
db["key2"] = "value2"
db["key3"] = "value3"
db["otherKey"] = "otherValue"
matches = db.prefix("key")
for key in matches:
print(f"{key}: {db[key]}")
This code only outputs the keys that start with the prefix “key”, so it doesn’t output “otherKey”.
2 Likes
system
Closed
December 19, 2022, 10:48pm
9
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.