fix sql bugs
Encoding bug fixed
json bug fixed
SQL bugs fixed