AlanHorman AlanHorman - 1 month ago 14
Python Question

Python PyQt5: Cannot save JPG files into database

I already asked how to save image data into phpmyadmin database. Python PyQt5: Store image data into a phpmyadmin database

This problem is solved, but there is another problem:
When I uploaded a jpg file (size: 6.64 MB) following error occurs:
(2013, 'Lost connection to MySQL server during query ([WinError 10053]...)

I think the source of this problem is that the size is too big.

Should I only use images with less than 1 MB or is there a possibillity to upload jpg files with sizes of over 6 MB?

Answer

You can try to modify your my.cnf or my.ini file. The files are located at BASEDIR\my.ini and BASEDIR\my.cnf (.ini is for Windows and .cnf is for unix). In that file, find [mysqld] section and add the following line to change the maximum allowed packet:

max_allowed_packet=10M

Good luck.