Ask coding questions

← Back to all posts
Array in database
Kingq23 (38)

I need help in making's database use a array for saving user data

Answered by Coder100 (18148) [earned 5 cycles]
View Answer
Coder100 (18148)

You can't just append to an array, you must use something like this:

temp = database['<ARRAY>']
database['<ARRAY>'] = temp
Kingq23 (38)

I am confused how can i use with replit database and also thank you

19wintersp (1142)

@qadams2008 You need to replace <ARRAY> with the pair key.

Kingq23 (38)

@19wintersp hopefully my last question but how do I get the pair key

Coder100 (18148)

that's the key you set it to like

from replit import db
db['name'] = 5

in this case name is that pair key

Kingq23 (38)

@Coder100 last question how would get it from the database

19wintersp (1142)

The Replit Python module will JSON-serialise Python objects automatically, so if you try to use a list as a database value, it should work properly.

Kingq23 (38)

@19wintersp how would I do this please give an example and thank you

19wintersp (1142)

@qadams2008 I didn't see you were appending, see @Coder100's answer.