Prometheus exporter for SQL queries

I have written an exporter using python client to generate metrics based on SQL queries.
So, the SQL query would return a data which is passed as a gauge metric to prometheus.
Everytime the SQL query runs, it either creates a new metric or changes value to already set gauge.
The issue is, when the next time the SQL query is executed, it may return a new metric with set of new label values. But in grafana time series table when I check, I still see the old data which is not returned by the query.
If I give _metrics.clear(), it removes the previous history of the metrics.
I want the old data in history but only want the new metrics to be extracted everytime.
How to achieve this?