• 我们在哪一颗星上见过 ,以至如此相互思念 ;我们在哪一颗星上相互思念过,以至如此相互深爱
  • 我们在哪一颗星上分别 ,以至如此相互辉映 ;我们在哪一颗星上入睡 ,以至如此唤醒黎明
  • 认识世界 克服困难 洞悉所有 贴近生活 寻找珍爱 感受彼此

sqlite3 操作语句

软件操作 云涯 4年前 (2020-04-08) 1780次浏览

清空表 将ID还原为1

delete from not_completed; 清空表
update sqlite_sequence set seq=0 where name=’not_completed’;  将ID还原为1

 

无则插入,有则忽略

cert_id是主键

insert or IGNORE into cert_temp (IOC,cert_id) VALUES (‘duckdns.org’,’11111.crt’);

 

单双引号转义

sqlite3_upd = “update cert_temp set cert_parse_context = ? where cert_id = ?”
cursor.execute(sqlite3_upd,(cert_parse_context,cert_id))

 

查询是否存在

sel_is_exist = “select * from user_ip_already_completed where ip_already_completed = \'”+ip+”\'”
a = cursor.execute(sel_is_exist)
conn.commit()
if len(list(a)) !=0:#如果数据库里有 置为0就行了

 

比对两个表的不同

SELECT ID,already_completed
from (
SELECT ID,already_completed from domain_already_completed
union ALL
SELECT ID,not_completed from domain_not_completed
)tb1
GROUP BY already_completed
HAVING count(already_completed) =1
ORDER BY ID;

 

 


云涯历险记 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:sqlite3 操作语句
喜欢 (0)