here are some things that belong:
All DBI calls should be checked for errors
All scripts or modules should have “use strict” and “use warnings”
Subroutines should NOT open and close the database every time. The DBI handle (usually $dbh) should be passed as a parameter from the main script running. Opening the DB every time will impose a performance and overhead penalty for large or busy installations, limiting Koha's ability to scale.