<jupyter_start><jupyter_text>Queries<jupyter_code>#Open a connection to postgres and create a connection object
conn = psycopg2.connect(host='localhost', dbname='postgres', user='postgres', password=password)

query = '''
    SELECT (MIN(ri), MAX(ri)) AS range_ri, (MIN(na), MAX(na)) AS range_na, (MIN(mg), MAX(mg)) AS range_mg,
        (MIN(al), MAX(al)) AS range_al, (MIN(si), MAX(si)) AS range_si, (MIN(k), MAX(k)) AS range_k,
        (MIN(ca), MAX(ca)) AS range_ca, (MIN(ba), MAX(ba)) AS range_ba, (MIN(fe), MAX(fe)) AS range_fe
    FROM observation_data d
    JOIN observation_class c ON d.observation_id = c.observation_id
    GROUP BY c.class_id;'''

#Reads sql query into a dataframe
pd.read_sql(query, conn)
query = '''
    SELECT MAX(ri) as max_ri, MAX(na) AS max_na, MAX(mg) AS max_mg, MAX(al) AS max_al, MAX(si) AS max_si, 
        MAX(k) AS max_k, MAX(ca) AS max_ca, MAX(ba) AS max_ba, MAX(fe) AS max_fe
    FROM observation_data d
    JOIN observation_class c ON d.observation_id = c.observation_id
    GROUP BY c.class_id;'''

#Reads sql query into a dataframe
pd.read_sql(query, conn)
query = '''
    SELECT MIN(ri) as min_ri, MIN(na) AS min_na, MIN(mg) AS min_mg, MIN(al) AS min_al, MIN(si) AS min_si, 
        MIN(k) AS min_k, MIN(ca) AS min_ca, MIN(ba) AS min_ba, MIN(fe) AS min_fe
    FROM observation_data d
    JOIN observation_class c ON d.observation_id = c.observation_id
    GROUP BY c.class_id;'''

#Reads sql query into a dataframe
pd.read_sql(query, conn)
#Close connection
conn.close()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13333333333333333, 'fraction_numerical': 0.0006472491909385113, 'mean_word_length': 4.443661971830986, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '38720', 'license': 'MIT', 'n_tokens_mistral': 600, 'n_tokens_neox': 588, 'n_words': 174, 'path': 'ETL Code.ipynb', 'repo_name': 'madisonmassie/Final_Project', 'size': '1545'}