I have a python script that performs an sql query and writes the output of the query to a .json file. However, every time it writes to the json file for me it overwrites the previously written text. I want each sql query to be written to a new and separate .json. Below is my code that is not working. Any help would be greatly appreciated!
from __future__ import print_function
try:
import psycopg2
except ImportError:
raise ImportError('\n\033[33mpsycopg2 library missing. pip install psycopg2\033[1;m\n')
sys.exit(1)
import re
import sys
import json
DB_HOST = 'crt.sh'
DB_NAME = 'certwatch'
DB_USER = 'guest'
OUTPUT_DIR="output/"
def connect_to_db(domain_name):
try:
conn = psycopg2.connect("dbname={0} u