当前位置: 移动技术网 > IT编程>开发语言>Delphi > JSON文本文件导入到Sqlite3数据库(04)

JSON文本文件导入到Sqlite3数据库(04)

2020年03月09日  | 移动技术网IT编程  | 我要评论

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;

3】换成csv文件,分隔符为$,然后将结果拷贝到excel里,再将excel文件导入到navicat for sqlite,完美!

update ciauthor set  name='作者介绍:'||name
insert 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.content
from 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 
--vacuum

insert 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 

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网