2/3 change unsafe asprintf functions to prevent sqlite injections
3/3 change unsafe asprintf functions to prevent sqlite injections and split duplicit query