Looks like this function was copy-pasted from `mysql.py`, I think we should extract it in another Python module that we import here, so that we don't have duplicated code.