<jupyter_start><jupyter_text><jupyter_code># SQL with a relational database
# author: <NAME>
# license: MIT License # code: github.com/gressling/examples
# activity: single example # index: 25-1 
import psycopg2
conn = psycopg2.connect("dbname='example_db' user='dbuser'
 host='localhost' password='password'")
cur = conn.cursor()
cur.execute("""SELECT * from results where yield>80""")
rows = cur.fetchall()
for row in rows:
 print(" ", row[0])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15157894736842106, 'fraction_numerical': 0.016842105263157894, 'mean_word_length': 6.80327868852459, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 7, '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': '508519', 'license': 'MIT', 'n_tokens_mistral': 167, 'n_tokens_neox': 160, 'n_words': 40, 'path': '25_1_SQL_with_a_relational_database.ipynb', 'repo_name': 'Gressling/examples', 'size': '481'}