①在终端下进入sqlite命令行:
sqlite3 20190507.db
②退出命令行:
.q
③查看表结构:
select * from sqlite_master WHERE type = "table";
④shell脚本中执行sql语句:
sqlite3 /work/songqiang/test.db << !
delete from company where age= '18' ;
select 'import: '||count(*) from company ;
.q
!
⑤拼接sql语句:
select pthread_type, cdr_id, duration ,'{sum}',duration/('{sum}'+0)
from tot_info
where file_name = '{file_name}'
order by duration desc ;'''.format(file_name=filename,sum=cds[0][0])
⑥sql中将字符串转换为数字:
SELECT '123'+0;