Add DatabaseErrorCode
Posted: Wed May 13, 2020 10:46 am
I have the problem that the MySQL connection gets lost after about 10 minutes due to the MySQL server setup. It would be quite easy to reconnect having the error code. The currently only build in way is parsing the error string that is returned by DatabaseError().
My workaround is importing the mysql_errno function from the library. So I think it is quite easy to add this as a native Purebasic function.
List of error codes: https://dev.mysql.com/doc/refman/8.0/en ... rence.html
TL;DR: It would be great to have a function DatabaseErrorCode() additionally to DatabaseError().
My workaround is importing the mysql_errno function from the library. So I think it is quite easy to add this as a native Purebasic function.
Code: Select all
ImportC "-lmariadb"
mysql_errno.l(id.i)
EndImport
Define db.i = DatabaseID(#Database)
Define errorCode.l = mysql_errno(db)
If errorCode = 2006 Or errorCode = 2013
Debug "Do the reconnect"
EndIf
TL;DR: It would be great to have a function DatabaseErrorCode() additionally to DatabaseError().