How can I give a correct error in the database? When I save the product, when the video file is not supported, it gives a correct error. Please look at the codes and tell me the problem.
for row in cur.execute(‘SELECT rowid, id, img, note FROM pics ORDER BY id’):
with st.form(f’ID-{row[0]}',clear_on_submit=True):
imgcol, notecol = st.columns([3, 2])
id=notecol.text_input(‘کد محصول’, row[1])
note=notecol.text_area(‘نام محصول’, row[3])
if row[2]:
img=row[2]
imgcol.image(row[2])
file=imgcol.file_uploader(‘تصاویر’, [‘png’, ‘jpg’, ‘gif’,‘jpeg’, ‘bmp’,‘mp4’])
if file:
img=file.read()
if notecol.form_submit_button(‘ذخیره محصول’):
cur.execute(
'UPDATE pics SET id=?, img=?, note=? WHERE id=?;',
(id, img, note, str(row[1]))
)
con.commit()
st.experimental_rerun()
if notecol.form_submit_button("حذف محصول"):
cur.execute(f'''DELETE FROM pics WHERE rowid="{row[0]}";''')
con.commit()
st.experimental_rerun()