<jupyter_start><jupyter_text>Postgres<jupyter_code>import psycopg2
conn = psycopg2.connect(dbname='dsp_dev', user='postgres', host='172.16.58.3', password='<PASSWORD>')
cur = conn.cursor()
cur.execute("SELECT datname FROM pg_database")
rows = cur.fetchall()
rows
def select(query):
    curr = conn.cursor()
    cur.execute(query)
    rows = cur.fetchall()
    return rows
select("""SELECT
   *
FROM
   pg_catalog.pg_tables
WHERE
   schemaname != 'pg_catalog'
AND schemaname != 'information_schema';""")
select("SELECT * FROM polls_question")<jupyter_output><empty_output><jupyter_text>Django ORM<jupyter_code>import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
import django
from django.contrib import admin
django.setup()
from polls.models import Question
from django.db import models
q0 = list(Question.objects.all())[0]
q0
q0.question_text
q2 = Question(question_text="How's Rudy doing?", pub_date=q0.pub_date)
q2.save()
Question.objects.all()
for q in Question.objects.all():
    print(q.question_text)<jupyter_output>What's a rat?
What's a whistle blower
How's Kelly-Ann doing?
How's Rudy doing?
{'fraction_non_alphanumeric': 0.13422222222222221, 'fraction_numerical': 0.015111111111111112, 'mean_word_length': 6.359477124183006, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '430450', 'license': 'Apache-2.0', 'n_tokens_mistral': 411, 'n_tokens_neox': 396, 'n_words': 84, 'path': 'mysite/Postgres.ipynb', 'repo_name': 'smurve/cbrokerage', 'size': '1126'}