vtcbca / internal-exam-23bca310

23bca-python-sqlite-internal-exam-303-PYTHON-EXAM created by GitHub Classroom
0 stars 0 forks source link

trigger #3

Open 23bca310 opened 1 month ago

23bca310 commented 1 month ago

explain trigger syntax

23bca311 commented 1 month ago

cur.execute(''' create trigger if not exists product_rate_qty before insert on product for each row begin select case when new.prate = 0 THEN raise (abort, 'Product rate cannot be zero.') when new.pqty = 0 THEN raise (abort, 'Product quantity cannot be zero.') end; end; ''')

23bca310 commented 1 month ago

how to write table data into csv file using writer object

23bca311 commented 1 month ago

with open('product2.csv','w',newline='')as file: writer=csv.writer(file) writer.writerow(['userid','pid','pname','prate','pqty'])

explain this code