I have a database from which I get user data and write it to a json
file.
This is structure:
The problem is that I get the value right away. How to get a key, too, not like this
[
54,
"newuser",
"newuser",
"newuser@mail.ru",
"2020-06-30",
"qweqwe123",
123123123,
"description"
],
but just like this
{
"id": "54",
"firstname": "newuser",
"lastname": "newuser",
"email": "newuser@mail.ru",
"born_date": "qweqwe123",
"password": "34962",
"phone_number": "123123123",
"description": "description"
},
code:
@app.route('/register', methods=['GET', 'POST'])
def register():
cur = mysql.connection.cursor()
cur.execute("SELECT * FROM users.data")
account = cur.fetchall()
description = account
content = {}
content = description
with open('data_json.json', 'w') as json_file:
json.dump(content, json_file, indent=4)
return render_template('profile.html')