Ask coding questions

← Back to all posts
replit database value int instead of string
h
Kingq23 (38)

is it possible and if not is there another way to get around this.

Comments
hotnewtop
ch1ck3n (2077)

db["whatever"] = str(8)
print(int(db["whatever"]) + 38)

the str( ) function converts it to a string, and the int() function coverts to a int

Kingq23 (38)

@ch1ck3n then what am I doing wrong

Ignoring exception in on_message
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event
await coro(*args, **kwargs)
File "main.py", line 19, in on_message
cur_mon = int(db[message.author])
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/replit/database/database.py", line 432, in getitem
raw_val = self.get_raw(key)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/replit/database/database.py", line 470, in get_raw
r = self.sess.get(self.db_url + "/" + urllib.parse.quote(key))
File "/usr/lib/python3.8/urllib/parse.py", line 851, in quote
return quote_from_bytes(string, safe)
File "/usr/lib/python3.8/urllib/parse.py", line 876, in quote_from_bytes
raise TypeError("quote_from_bytes() expected bytes")
TypeError: quote_from_bytes() expected bytes

ch1ck3n (2077)

@qadams2008 ya first gotta make your repl public