Answer the question
In order to leave comments, you need to log in
How to change value in SQLite json?
Good afternoon !
The question is.. How to change values in sqlite if there is json ? I wanted to change the value of the id line to another
with sqlite3.connect('base.db') as conn:
cursor = conn.cursor()
cursor.execute(f"SELECT nabor FROM inv where ids={ctx.author.id}")
data = cursor.fetchall()
print(data)
data['id'] = '99'
#Как записать в data значение 99 обратно в базу ?
Answer the question
In order to leave comments, you need to log in
with sqlite3.connect('base.db') as conn:
cursor = conn.cursor()
cursor.execute(f"UPDATE inv SET nabor = json_replace(nabor, '$.id', 99) WHERE ids={ctx.author.id}")
con.commit()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question