JSON文本文件导入到Sqlite3数据库(04)
作者:互联网
1】Navicat for SQLite ,直接导入,会出现好多问题,即使导入成功,最后一个字经常会是乱码,这方法放弃
2】编程转换,JSON文本文件中有好多偏僻字,Delphi 里的UTF8toAnsi函数往往不成功,这方法放弃/因为Delphi自带的转换函数遇到其无法识别的字符串就返回空
function DecodeUtf8Str(const S: UTF8String): WideString; var lenSrc, lenDst : Integer; begin lenSrc := Length(S); if(lenSrc=0)then Exit; lenDst := MultiByteToWideChar(CP_UTF8, 0, Pointer(S), lenSrc, nil, 0); SetLength(Result, lenDst); MultiByteToWideChar(CP_UTF8, 0, Pointer(S), lenSrc, Pointer(Result), lenDst); end;
DecodeUtf8Str解决系统自带UTF8解码缺陷
3】JSON文本文件在线转换成CSV文件,分隔符为$,然后将结果拷贝到Excel里,再将Excel文件导入到Navicat for SQLite,完美!
UPDATE ciauthor set name='作者介绍:'||nameinsert into atb (id,name,info) select ciauthor.value+64051,ciauthor.name,ciauthor.long_desc from ciauthor insert into atb (id,name,info) select ci.value+65641,ci.rhythmic||'-'||ci.author,ci.contentfrom ci insert into atb (id,name,info) select 86691+ROWid, aa.title||'-'||aa.author,aa.paragraphs from aa insert into atb (id,name,info) select 97748+ROWid, '幽梦影-张潮'||ROWid, aa.content||'---'||aa.comment from aa --VACUUMinsert into atb (id,name,info) select 98415+ rowID, aax.title||'--'||aax.author ,aax.notes||'--'||aax.paragraphs from aax--insert into atb (id,name,info) select 99513+ROWid , Sheet1.title||'--'||Sheet1.author,Sheet1.paragraphs from Sheet1
用到的SQL
标签:导入到,aa,atb,name,04,into,JSON,info,select 来源: https://blog.51cto.com/u_15216366/2823755