<commit_before># -*- coding: utf-8 -*-
from flask import Flask
import os
import psycopg2
from contextlib import closing

# TODO: add owner_id constraint
DB_SCHEMA = """
DROP TABLE IF EXISTS lists;
CREATE TABLE lists (
    list_id serial PRIMARY KEY,
    title VARCHAR (127) NOT NULL,
    description TEXT,
    owner_id INT
)
"""

app = Flask(__name__)

app.config['DATABASE'] = os.environ.get('DATABASE_URL',
                                        'dbname=wist user=Michelle')

def connect_db():
    """Return connection to configured db"""
    return psycopg2.connect(app.config['DATABASE'])


def init_db():
    """Initialize database using DB_SCHEMA"""
    with closing(connect_db()) as db:
        db.cursor().execute(DB_SCHEMA)
        db.commit()

@app.route('/')
def welcome():
    return u"Welcome to Wist"

if __name__ == '__main__':
    app.run(debug=True)<commit_msg>added connection to db<commit_after># -*- coding: utf-8 -*-
from flask import Flask
from flask import g
import os
import psycopg2
from contextlib import closing

# TODO: add owner_id constraint
DB_SCHEMA = """
DROP TABLE IF EXISTS lists;
CREATE TABLE lists (
    list_id serial PRIMARY KEY,
    title VARCHAR (127) NOT NULL,
    description TEXT,
    owner_id INT
)
"""

app = Flask(__name__)

app.config['DATABASE'] = os.environ.get('DATABASE_URL',
                                        'dbname=wist user=Michelle')

def connect_db():
    """Return connection to configured db"""
    return psycopg2.connect(app.config['DATABASE'])


def init_db():
    """Initialize database using DB_SCHEMA"""
    with closing(connect_db()) as db:
        db.cursor().execute(DB_SCHEMA)
        db.commit()


def get_database_connection():
    db = getattr(g, 'db', None)
    if not db:
        g.db = db = connect_db()
    return db


@app.teardown_request
def teardown_request(exception):
    db = getattr(g, 'db', None)
    if db:
        if exception and isinstance(exception, psycopg2.Error):
            # rollback if any errors
            db.rollback()
        else:
            # otherwise, good to commit
            db.commit()
        db.close()


@app.route('/')
def welcome():
    return u"Welcome to Wist"

if __name__ == '__main__':
    app.run(debug=True)
{'fraction_non_alphanumeric': 0.11924966502903082, 'fraction_numerical': 0.005806163465832961, 'mean_word_length': 2.8421955403087478, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6112800', 'n_tokens_mistral': 724, 'n_tokens_neox': 704, 'n_words': 204}