Database function bugfix for new sqlite version