modifying rand functions to use mysql instead of sqlite