清空表 将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;