List of dates with special formatting
With the list comprehension you are filling a whole list with your values, and then you are sending that list to join.

Instead of a generating a list and then sending it, you can send a generator instead: similar to the list comprehension, but generates the values on-demand. With your old approach, if you had 10000 dates you would have them all at a list; with a generator it generates one at a time, so at least you will be consuming less memory.

With a generator, you would directly do:

dates = "('" + "'),('".join(str(start_date + dt.timedelta(d)) for d in range(day_diff)) + "')"


On a side note, the parameter names date1, date2 are not very explicit; it should be clear from the names which is the start and which is the end date.