I know this is not an answer to your question. But sharing how i am handling the exact requirement of mine. What i do is to select the distinct expiry dates from http://public.fyers.in/sym_details/NSE_FO.csv420. Setup a cron to clear old data and update the database comparing current date, so that it remains updated on each day.
I have another table for holidays, where the trading holidays are collected from nse website https://www.nseindia.com/resources/exchange-communication-holidays560. Once in a year process.