{"action":"created","comment":{"url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/pulls/comments/189447862","pull_request_review_id":121632511,"id":189447862,"diff_hunk":"@@ -0,0 +1,99 @@\n+import pymongo\n+import mysql.connector\n+import json\n+from pymongo import MongoClient\n+\n+with open('config.json') as f:\n+    config = json.load(f)\n+\n+dbs = mysql.connector.connect(host=config['sql']['host'],    # your host, usually localhost\n+                     user=config['sql']['user'],         # your username\n+                     passwd=config['sql']['pass'],  # your password\n+                     db=config['sql']['db']) \n+\n+client = MongoClient(config['mongo']['uri'])\n+db = client.local\n+\n+\n+# for builiding in db['buildings'].find({},{'name': 1, 'data_entries' : 0}):\n+# \tprint building\n+sql = dbs.cursor()\n+\n+sql.execute('SHOW TABLES LIKE \"buildings\"')\n+\n+if not sql.fetchone():\n+\tsql.execute('CREATE TABLE buildings (id int NOT NULL AUTO_INCREMENT, Name CHAR(64), sus_map_id CHAR(64), PRIMARY KEY (id))')\n+\tfor building in db.buildings.find({}):\n+\t\tsql.execute('INSERT INTO buildings (Name,sus_map_id) VALUES (\"%s\",\"%s\")'%(building['name'],''))\n+\n+# sql.execute('SELECT * FROM buildings')\n+# for row in sql.fetchall():\n+# \tprint str(row[0]) + \" \" + str(row[1]) + \" \" + str(row[2])\n+\n+sql.execute('SHOW TABLES LIKE \"meters\"')\n+if not sql.fetchone():\n+\tsql.execute('CREATE TABLE meters (id int NOT NULL AUTO_INCREMENT, Name CHAR(64), address CHAR(16), building_id int, operation bit, PRIMARY KEY (id), FOREIGN KEY (building_id) REFERENCES buildings(id))')\n+\tfor building in db.buildings.find({}):\n+\t\tsql.execute('SELECT id FROM buildings WHERE Name = \"%s\"'%(building['name']))\n+\t\tsid = sql.fetchone()[0]\n+\t\tfor meter in db.meters.find({ '_id' : { '$in' : building['meters']}}):\n+\t\t\tsql.execute('INSERT INTO meters (Name, address, building_id, operation) VALUES (\"%s\",\"%s\",%d,1)'%(meter['name'],meter['meter_id'],sid))\n+\tfor meter in db.meters.find({}):\n+\t\tif meter['meter_id'].find('_') >= 0:\n+\t\t\tsql.execute('SELECT * FROM meters WHERE address = \"%s\"'%(meter['meter_id']))\n+\t\t\tif not sql.fetchone():\n+\t\t\t\tsql.execute('INSERT INTO meters (Name, address) VALUES (\"%s\",\"%s\")'%(meter['name'],meter['meter_id']))\n+\n+dbs.commit();\n+\n+sql.execute('SHOW TABLES LIKE \"data\"')\n+if not sql.fetchone():\n+\tsql.execute('CREATE TABLE data (id int NOT NULL AUTO_INCREMENT, building_id int, time TIMESTAMP, accumulated_real int, real_power float, reactive_power float, apparent_power float, real_a float, real_b float, real_c float, reactive_a float, reactive_b float, reactive_c float, apparent_a float, apparent_b float, apparent_c float, pf_a float, pf_b float, pf_c float, vphase_ab float, vphase_bc float, vphase_ac float, vphase_an float, vphase_bn float, vphase_cn float, cphase_a float, cphase_b float, cphase_c float, PRIMARY KEY (id), FOREIGN KEY (building_id) REFERENCES buildings(id))')\n+\t#table population script \n+\n+# sql.execute('SHOW TABLES LIKE \"temp_data\"')","path":"python/importData.py","position":54,"original_position":54,"commit_id":"3ec92c251ec9fab7ba7f6aa2006b919fc224fc52","original_commit_id":"3ec92c251ec9fab7ba7f6aa2006b919fc224fc52","user":{"login":"jackrwoods","id":19655338,"avatar_url":"https://avatars0.githubusercontent.com/u/19655338?v=4","gravatar_id":"","url":"https://api.github.com/users/jackrwoods","html_url":"https://github.com/jackrwoods","followers_url":"https://api.github.com/users/jackrwoods/followers","following_url":"https://api.github.com/users/jackrwoods/following{/other_user}","gists_url":"https://api.github.com/users/jackrwoods/gists{/gist_id}","starred_url":"https://api.github.com/users/jackrwoods/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jackrwoods/subscriptions","organizations_url":"https://api.github.com/users/jackrwoods/orgs","repos_url":"https://api.github.com/users/jackrwoods/repos","events_url":"https://api.github.com/users/jackrwoods/events{/privacy}","received_events_url":"https://api.github.com/users/jackrwoods/received_events","type":"User","site_admin":false},"body":"What are these comments for? It seems like a bunch of stuff is commented out.","created_at":"2018-05-20T00:12:25Z","updated_at":"2018-05-20T00:16:06Z","html_url":"https://github.com/OSU-Sustainability-Office/energy-dashboard/pull/6#discussion_r189447862","pull_request_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/pulls/6","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/pulls/comments/189447862"},"html":{"href":"https://github.com/OSU-Sustainability-Office/energy-dashboard/pull/6#discussion_r189447862"},"pull_request":{"href":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/pulls/6","id":189212417,"html_url":"https://github.com/OSU-Sustainability-Office/energy-dashboard/pull/6","diff_url":"https://github.com/OSU-Sustainability-Office/energy-dashboard/pull/6.diff","patch_url":"https://github.com/OSU-Sustainability-Office/energy-dashboard/pull/6.patch","issue_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/issues/6","number":6,"state":"open","locked":false,"title":"Added python scripts to pull data from mongo and upload to sql","user":{"login":"broha22","id":6435189,"avatar_url":"https://avatars3.githubusercontent.com/u/6435189?v=4","gravatar_id":"","url":"https://api.github.com/users/broha22","html_url":"https://github.com/broha22","followers_url":"https://api.github.com/users/broha22/followers","following_url":"https://api.github.com/users/broha22/following{/other_user}","gists_url":"https://api.github.com/users/broha22/gists{/gist_id}","starred_url":"https://api.github.com/users/broha22/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/broha22/subscriptions","organizations_url":"https://api.github.com/users/broha22/orgs","repos_url":"https://api.github.com/users/broha22/repos","events_url":"https://api.github.com/users/broha22/events{/privacy}","received_events_url":"https://api.github.com/users/broha22/received_events","type":"User","site_admin":false},"body":"Look at this for information on tables and and the algorithm for putting data from temp to perm.","created_at":"2018-05-20T00:06:17Z","updated_at":"2018-05-20T00:16:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"abc60728c00454a3167ad072a3a25b47b501c328","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/pulls/6/commits","review_comments_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/pulls/6/comments","review_comment_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/pulls/comments{/number}","comments_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/issues/6/comments","statuses_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/statuses/3ec92c251ec9fab7ba7f6aa2006b919fc224fc52","head":{"label":"OSU-Sustainability-Office:brogan","ref":"brogan","sha":"3ec92c251ec9fab7ba7f6aa2006b919fc224fc52","user":{"login":"OSU-Sustainability-Office","id":35615921,"avatar_url":"https://avatars2.githubusercontent.com/u/35615921?v=4","gravatar_id":"","url":"https://api.github.com/users/OSU-Sustainability-Office","html_url":"https://github.com/OSU-Sustainability-Office","followers_url":"https://api.github.com/users/OSU-Sustainability-Office/followers","following_url":"https://api.github.com/users/OSU-Sustainability-Office/following{/other_user}","gists_url":"https://api.github.com/users/OSU-Sustainability-Office/gists{/gist_id}","starred_url":"https://api.github.com/users/OSU-Sustainability-Office/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OSU-Sustainability-Office/subscriptions","organizations_url":"https://api.github.com/users/OSU-Sustainability-Office/orgs","repos_url":"https://api.github.com/users/OSU-Sustainability-Office/repos","events_url":"https://api.github.com/users/OSU-Sustainability-Office/events{/privacy}","received_events_url":"https://api.github.com/users/OSU-Sustainability-Office/received_events","type":"Organization","site_admin":false},"repo":{"id":133889523,"name":"energy-dashboard","full_name":"OSU-Sustainability-Office/energy-dashboard","owner":{"login":"OSU-Sustainability-Office","id":35615921,"avatar_url":"https://avatars2.githubusercontent.com/u/35615921?v=4","gravatar_id":"","url":"https://api.github.com/users/OSU-Sustainability-Office","html_url":"https://github.com/OSU-Sustainability-Office","followers_url":"https://api.github.com/users/OSU-Sustainability-Office/followers","following_url":"https://api.github.com/users/OSU-Sustainability-Office/following{/other_user}","gists_url":"https://api.github.com/users/OSU-Sustainability-Office/gists{/gist_id}","starred_url":"https://api.github.com/users/OSU-Sustainability-Office/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OSU-Sustainability-Office/subscriptions","organizations_url":"https://api.github.com/users/OSU-Sustainability-Office/orgs","repos_url":"https://api.github.com/users/OSU-Sustainability-Office/repos","events_url":"https://api.github.com/users/OSU-Sustainability-Office/events{/privacy}","received_events_url":"https://api.github.com/users/OSU-Sustainability-Office/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OSU-Sustainability-Office/energy-dashboard","description":"Oregon State University's energy dashboard.","fork":false,"url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard","forks_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/forks","keys_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/teams","hooks_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/hooks","issue_events_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/issues/events{/number}","events_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/events","assignees_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/assignees{/user}","branches_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/branches{/branch}","tags_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/tags","blobs_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/git/refs{/sha}","trees_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/statuses/{sha}","languages_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/languages","stargazers_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/stargazers","contributors_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/contributors","subscribers_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/subscribers","subscription_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/subscription","commits_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/commits{/sha}","git_commits_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/git/commits{/sha}","comments_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/comments{/number}","issue_comment_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/issues/comments{/number}","contents_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/contents/{+path}","compare_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/merges","archive_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/downloads","issues_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/issues{/number}","pulls_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/pulls{/number}","milestones_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/milestones{/number}","notifications_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/labels{/name}","releases_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/releases{/id}","deployments_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/deployments","created_at":"2018-05-18T01:56:38Z","updated_at":"2018-05-19T01:51:31Z","pushed_at":"2018-05-20T00:06:18Z","git_url":"git://github.com/OSU-Sustainability-Office/energy-dashboard.git","ssh_url":"git@github.com:OSU-Sustainability-Office/energy-dashboard.git","clone_url":"https://github.com/OSU-Sustainability-Office/energy-dashboard.git","svn_url":"https://github.com/OSU-Sustainability-Office/energy-dashboard","homepage":null,"size":34374,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":6,"license":null,"forks":0,"open_issues":6,"watchers":0,"default_branch":"master"}},"base":{"label":"OSU-Sustainability-Office:master","ref":"master","sha":"850cfb3d52b23520023de43ecdf3d2eabcbf6096","user":{"login":"OSU-Sustainability-Office","id":35615921,"avatar_url":"https://avatars2.githubusercontent.com/u/35615921?v=4","gravatar_id":"","url":"https://api.github.com/users/OSU-Sustainability-Office","html_url":"https://github.com/OSU-Sustainability-Office","followers_url":"https://api.github.com/users/OSU-Sustainability-Office/followers","following_url":"https://api.github.com/users/OSU-Sustainability-Office/following{/other_user}","gists_url":"https://api.github.com/users/OSU-Sustainability-Office/gists{/gist_id}","starred_url":"https://api.github.com/users/OSU-Sustainability-Office/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OSU-Sustainability-Office/subscriptions","organizations_url":"https://api.github.com/users/OSU-Sustainability-Office/orgs","repos_url":"https://api.github.com/users/OSU-Sustainability-Office/repos","events_url":"https://api.github.com/users/OSU-Sustainability-Office/events{/privacy}","received_events_url":"https://api.github.com/users/OSU-Sustainability-Office/received_events","type":"Organization","site_admin":false},"repo":{"id":133889523,"name":"energy-dashboard","full_name":"OSU-Sustainability-Office/energy-dashboard","owner":{"login":"OSU-Sustainability-Office","id":35615921,"avatar_url":"https://avatars2.githubusercontent.com/u/35615921?v=4","gravatar_id":"","url":"https://api.github.com/users/OSU-Sustainability-Office","html_url":"https://github.com/OSU-Sustainability-Office","followers_url":"https://api.github.com/users/OSU-Sustainability-Office/followers","following_url":"https://api.github.com/users/OSU-Sustainability-Office/following{/other_user}","gists_url":"https://api.github.com/users/OSU-Sustainability-Office/gists{/gist_id}","starred_url":"https://api.github.com/users/OSU-Sustainability-Office/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/OSU-Sustainability-Office/subscriptions","organizations_url":"https://api.github.com/users/OSU-Sustainability-Office/orgs","repos_url":"https://api.github.com/users/OSU-Sustainability-Office/repos","events_url":"https://api.github.com/users/OSU-Sustainability-Office/events{/privacy}","received_events_url":"https://api.github.com/users/OSU-Sustainability-Office/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/OSU-Sustainability-Office/energy-dashboard","description":"Oregon State University's energy dashboard.","fork":false,"url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard","forks_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/forks","keys_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/keys{/key_id}","collaborators_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/teams","hooks_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/hooks","issue_events_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/issues/events{/number}","events_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/events","assignees_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/assignees{/user}","branches_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/branches{/branch}","tags_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/tags","blobs_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/git/refs{/sha}","trees_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/git/trees{/sha}","statuses_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/statuses/{sha}","languages_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/languages","stargazers_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/stargazers","contributors_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/contributors","subscribers_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/subscribers","subscription_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/subscription","commits_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/commits{/sha}","git_commits_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/git/commits{/sha}","comments_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/comments{/number}","issue_comment_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/issues/comments{/number}","contents_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/contents/{+path}","compare_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/compare/{base}...{head}","merges_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/merges","archive_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/downloads","issues_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/issues{/number}","pulls_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/pulls{/number}","milestones_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/milestones{/number}","notifications_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/labels{/name}","releases_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/releases{/id}","deployments_url":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/deployments","created_at":"2018-05-18T01:56:38Z","updated_at":"2018-05-19T01:51:31Z","pushed_at":"2018-05-20T00:06:18Z","git_url":"git://github.com/OSU-Sustainability-Office/energy-dashboard.git","ssh_url":"git@github.com:OSU-Sustainability-Office/energy-dashboard.git","clone_url":"https://github.com/OSU-Sustainability-Office/energy-dashboard.git","svn_url":"https://github.com/OSU-Sustainability-Office/energy-dashboard","homepage":null,"size":34374,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":6,"license":null,"forks":0,"open_issues":6,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/pulls/6"},"html":{"href":"https://github.com/OSU-Sustainability-Office/energy-dashboard/pull/6"},"issue":{"href":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/issues/6"},"comments":{"href":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/OSU-Sustainability-Office/energy-dashboard/statuses/3ec92c251ec9fab7ba7f6aa2006b919fc224fc52"}},"author_association":"NONE"}}
{"actor":{"display_login":"jackrwoods"}}