<commit_before>import json
import psycopg2 as pg
from indra.statements import *
from indra.databases import hgnc_client

conn = None

def get_connection():
    global conn
    if conn is None:
        aws_host = 'indradb.cwcetxbvbgrf.us-east-1.rds.amazonaws.com'
        conn = pg.connect(host=aws_host, database='indra_db',
                          user='indra_db_user', password='<PASSWORD>')
    return conn

def create_tables():
    """Create the tables for the INDRA database."""
    conn = get_connection()
    sql = """
    CREATE TABLE text_ref (
        id serial PRIMARY KEY,
        source TEXT NOT NULL,
        pmid TEXT UNIQUE,
        pmcid TEXT UNIQUE,
        doi TEXT UNIQUE,
        url TEXT UNIQUE,
        manuscript_id TEXT UNIQUE,
        journal TEXT,
        publisher TEXT,
        pub_date DATE
    );
    CREATE TABLE text_content (
        id serial PRIMARY KEY,
        text_ref_id int4 NOT NULL REFERENCES text_ref(id),
        content_type TEXT NOT NULL,
        content BYTEA NOT NULL
    );
    CREATE TABLE reach (
        id serial PRIMARY KEY,
        text_content_id int4 NOT NULL REFERENCES text_content(id),
        version TEXT NOT NULL,
        json BYTEA NOT NULL
    );
    CREATE TABLE  db_info (
        id serial PRIMARY KEY,
        db_name TEXT NOT NULL,
        timestamp TIMESTAMP DEFAULT now()
    );
    CREATE TABLE statements (
        id serial PRIMARY KEY,
        uuid TEXT UNIQUE NOT NULL,
        db_ref int4 REFERENCES db_info(id),
        type TEXT NOT NULL,
        json TEXT NOT NULL
    );
    CREATE TABLE agents (
        id serial PRIMARY KEY,
        stmt_id int4 REFERENCES statements(id),
        db_name TEXT NOT NULL,
        db_id TEXT NOT NULL,
        role TEXT NOT NULL<commit_msg>Add unique constraint on text_content<commit_after>import json
import psycopg2 as pg
from indra.statements import *
from indra.databases import hgnc_client

conn = None

def get_connection():
    global conn
    if conn is None:
        aws_host = 'indradb.cwcetxbvbgrf.us-east-1.rds.amazonaws.<EMAIL>'
        conn = pg.connect(host=aws_host, database='indra_db',
                          user='indra_db_user', password='<PASSWORD>')
    return conn

def create_tables():
    """Create the tables for the INDRA database."""
    conn = get_connection()
    sql = """
    CREATE TABLE text_ref (
        id serial PRIMARY KEY,
        source TEXT NOT NULL,
        pmid TEXT UNIQUE,
        pmcid TEXT UNIQUE,
        doi TEXT UNIQUE,
        url TEXT UNIQUE,
        manuscript_id TEXT UNIQUE,
        journal TEXT,
        publisher TEXT,
        pub_date DATE
    );
    CREATE TABLE text_content (
        id serial PRIMARY KEY,
        text_ref_id int4 NOT NULL REFERENCES text_ref(id),
        content_type TEXT NOT NULL,
        content BYTEA NOT NULL,
        UNIQUE (text_ref_id, content_type)
    );
    CREATE TABLE reach (
        id serial PRIMARY KEY,
        text_content_id int4 NOT NULL REFERENCES text_content(id),
        version TEXT NOT NULL,
        json BYTEA NOT NULL,
        UNIQUE (text_content_id, version)
    );
    CREATE TABLE  db_info (
        id serial PRIMARY KEY,
        db_name TEXT NOT NULL,
        timestamp TIMESTAMP DEFAULT now()
    );
    CREATE TABLE statements (
        id serial PRIMARY KEY,
        uuid TEXT UNIQUE NOT NULL,
        db_ref int4 REFERENCES db_info(id),
        type TEXT NOT NULL,
        json TEXT NOT NULL
    );
    CREATE TABLE agents (
        id serial PRIMARY KEY,
        stmt_id int4 REFERENCES statements(id),
        db_name TEXT NOT NULL,
        db_id TEXT NOT NULL,
        role TEXT NOT NULL
{'fraction_non_alphanumeric': 0.06220754197632811, 'fraction_numerical': 0.0033030553261767133, 'mean_word_length': 2.113967437874893, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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}}
{'dir': 'git-commits-cleaned', 'id': '4078817', 'n_tokens_mistral': 1114, 'n_tokens_neox': 1077, 'n_words': 369}