Add database connect function and sql code.