SQL escape and format from mysql/lib/protocol/SqlString.js