0

I will go directly to the point; I'm having problems with accessing values in my Repl.it Database. I made an entire class in another file to access the database, I'm able to print out and return values but can't add values to a list in the database.

Here is my function (inside of a class) to add VIP members(discord) to the database:

def add_vip(self, db_name, user_id):
  if db_name in db:

    # Check if user not already in DB
    if user_id not in db[db_name]["users_id"]:
        db[db_name]["users_id"].append(user_id)

        # Verify if user was added
        return (True, "User added!", db[db_name]["users_id"], type(db[db_name]["users_id"]))

    else:
        return (False, "User already exists!", "Error")

else:
    return (False, "Db does not exist or lengh of user_id below 18 digits!", "Error"

The actual problem: It prints out the debugging return, and it prints out "True, "User added" and all that etc.. but it does not actually add it to the list inside of that key."

I feel like this may be a really dumb mistake that I just can't identify... Anyways I'm seeking the gods of Stackoverflow for this, thank you.

If you need more code just lmk and I'll send it!

This does not give me any errors That's why I did not post it here!

Newbie
  • 1
  • 1
  • `db[db_name]["users_id"] = user_id` That code doesn't add to a list... – John Gordon May 05 '21 at 02:16
  • Actually I'm so sorry, its supposed to be .append(user_id) Just edited it, that code was from me trying to just change values around to make it work. I currently have it like it is up there: .append(user_id) which should work as db[db_name]["users_id"] is a list – Newbie May 05 '21 at 02:19
  • Where is `db` defined? – John Gordon May 05 '21 at 02:43
  • Db is defined at the top: from replit import db a one liner giving to you by repl in the database section – Newbie May 05 '21 at 03:08
  • How do you know the userid isn't being added? Do you have some code that checks the database afterwards? Show us that code. – John Gordon May 05 '21 at 03:37

0 Answers0