I am currently using the code:
INSERT INTO tradecounts
SELECT symbol, tstamp, COUNT(*) AS trades
FROM (SELECT d.* FROM janw1 d ORDER BY entry_date ASC LIMIT 200000) d
GROUP BY tstamp, symbol HAVING COUNT(*) > 50
Which is working as intended however I would like to use python to run this statement every n number of seconds and when it does that it appends duplicate records so I need to put a WHERE NOT EXISTS statement in but I am having trouble with the syntax
insert INTO tradecounts
SELECT symbol, tstamp, COUNT(*) AS trades
FROM (SELECT d.* FROM janw1 d ORDER BY entry_date ASC LIMIT 200000) d
WHERE NOT EXISTS
GROUP BY tstamp, symbol HAVING COUNT(*) > 50
Any suggestions as to where I am going wrong would be much appreciated. Thank you!
symbol, tstampthen useinsert .. on conflict (..) do nothing