<commit_before>#!/usr/bin/env python


'''
Create the database structure for the monitoring program and the scripts
that operate on the data.  Populate it with some random rows for development
purposes.

This file essentially contains the current (as of writing) configuration
of sensors (and groups) on campus.
'''

import sys
sys.path.append('/var/local/energy/lib')
import psycopg2
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
from random import random, randint
from energyconfig2 import *


NUM_INSERTS = 10**3 # per sensor
INSERT_INTERVAL = 10 # seconds


def main():
    '''
    Build the database structure and populate with random rows.
    '''
    conn = psycopg2.connect(PSQL_CONNSTR)
    conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
    cur = conn.cursor()

    cur.execute('''CREATE TABLE sensor_groups 
                     (id serial primary key, 
                     name varchar(32) not null unique, 
                     color char(6));''')
    cur.execute('''CREATE TABLE sensors 
                     (id serial primary key, <commit_msg>Fixed bug in dev (no energyconfig2 for a while now!)<commit_after>#!/usr/bin/env python


'''
Create the database structure for the monitoring program and the scripts
that operate on the data.  Populate it with some random rows for development
purposes.

This file essentially contains the current (as of writing) configuration
of sensors (and groups) on campus.
'''

import sys
sys.path.append('/var/local/energy/lib')
import psycopg2
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
from random import random, randint
from energyconfig import *


NUM_INSERTS = 10**3 # per sensor
INSERT_INTERVAL = 10 # seconds


def main():
    '''
    Build the database structure and populate with random rows.
    '''
    conn = psycopg2.connect(PSQL_CONNSTR)
    conn.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
    cur = conn.cursor()

    cur.execute('''CREATE TABLE sensor_groups 
                     (id serial primary key, 
                     name varchar(32) not null unique, 
                     color char(6));''')
    cur.execute('''CREATE TABLE sensors 
                     (id serial primary key, 
{'fraction_non_alphanumeric': 0.07969034608378871, 'fraction_numerical': 0.01092896174863388, 'mean_word_length': 3.08364312267658, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '606151', 'n_tokens_mistral': 626, 'n_tokens_neox': 589, 'n_words': 217}