Ask coding questions

← Back to all posts
Array in repl.it database
h
Kingq23

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

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
KlemensKimmy
NugithChan
Kingq23
Comments
hotnewtop
Coder100

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

Kingq23

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

19wintersp

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

Kingq23

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

Coder100

that's the key you set it to like

@qadams2008
in this case name is that pair key

Kingq23

@Coder100 last question how would get it from the database

Coder100

you just do
db['key'] @qadams2008

19wintersp

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

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

19wintersp

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