import sqlite3
conn = sqlite3.connect('D:\\hskio_python.db')
try:
info = []
cur = conn.cursor()
rows = cur.execute('select * from person')
for row in rows:
id = row[0]
hei ght = row[2]
weight = row[3]
bmi = round(weight/height**2, 2)
print(id, height, weight, bmi)
info.append([bmi, id])
for data in info:
cur.execute('update person set bmi=%d where id=%d' % (data[0], data[1]))
conn.commit()
finally:
conn.close()
Sunday, June 7, 2020
python with database
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment