I want to check whether the emp_id and date has been already there in both bill_item and bill_item_temp tables or not? if not exists then i have to do insert?
s = CONN.cursor()
query = """insert into bill_item (id,product_name,price,create_date,emp_id)
select %s,%s,%s,%s,%s where not exists ( select 1 from bill_item where emp_id = %s and
select 1 from bill_item_ref where emp_id = %s);"""
s.execute(query,(id,product_name,price,create_date,emp_id,));
table: bill_item
id product_name price create_date emp_id
1 rice 10 2021-03-09 10:10:10.231321 12345
2 tea 10 2021-03-09 08:10:10.231321 22345
table: bill_item_temp
id product_name price create_date emp_id
1 drinks 10 2021-03-09 10:10:10.231321 67345
2 snacks 10 2021-03-09 08:10:10.231321 92345