Can json.dumps create multiple lines
Cecil Westerhof
Cecil at decebal.nl
Thu Dec 1 17:26:58 EST 2016
On Thursday 1 Dec 2016 22:52 CET, Cecil Westerhof wrote:
> Now I need to convert the database. But that should not be a big
> problem.
I did the conversion with:
cursor.execute('SELECT tipID FROM tips')
ids = cursor.fetchall()
for id in ids:
id = id[0]
cursor.execute('SELECT tip from tips WHERE tipID = ?', [id])
old_value = cursor.fetchone()[0]
new_value = json.dumps(json.loads(old_value), indent = 0)
cursor.execute('UPDATE tips SET tip = ? WHERE tipID = ?', [new_value, id])
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
More information about the Python-list
mailing list