Skip to content

Commit

Permalink
Adding ability to create tables for accuracy test suite database
Browse files Browse the repository at this point in the history
  • Loading branch information
navdeep-G committed Jan 12, 2016
1 parent 42fd4ec commit 1e8f2d1
Showing 1 changed file with 112 additions and 0 deletions.
112 changes: 112 additions & 0 deletions scripts/create_tables_mysql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import sys, os
import csv
import mysql.connector
import traceback

class CreateMysqlTables:
def __init__(self):
self = self

def drop_testcases_table(self):

#Connect to mysql database
h2o = mysql.connector.connect(user='root', password='0xdata', host='172.16.2.178', database='h2o')
cursor = h2o.cursor()

try:
drop_testcases_query = """
DROP TABLE IF EXISTS TestCases;
"""

cursor.execute(drop_testcases_query)
except:
traceback.print_exc()
h2o.rollback()
assert False, "Failed to drop TestCases table!"

cursor.close()
h2o.close()

def drop_acc_datasets_tables(self):

#Connect to mysql database
h2o = mysql.connector.connect(user='root', password='0xdata', host='172.16.2.178', database='h2o')
cursor = h2o.cursor()

try:
drop_accuracydata_query = """
DROP TABLES IF EXISTS AccuracyDatasets;
"""

cursor.execute(drop_accuracydata_query)
except:
traceback.print_exc()
h2o.rollback()
assert False, "Failed to drop AccuracyDatasets table!"

cursor.close()
h2o.close()

def create_testcases_table(self):

#Connect to mysql database
h2o = mysql.connector.connect(user='root', password='0xdata', host='172.16.2.178', database='h2o')
cursor = h2o.cursor()

#Drop table first before creation
self.drop_testcases_table()

#Create test cases table to be imputed into h2o database
try:
test_cases_query = """
CREATE TABLE TestCases(
test_case_id int(100) NOT NULL AUTO_INCREMENT,
algorithm varchar(100) NOT NULL,
algo_parameters varchar(200) NOT NULL,
tuned int(100) NOT NULL,
regression int(100) NOT NULL,
training_data_set_id int(100) NOT NULL,
testing_data_set_id int(100) NOT NULL,
PRIMARY KEY (`test_case_id`)
)"""

cursor.execute(test_cases_query)
except:
traceback.print_exc()
h2o.rollback()
assert False, "Failed to build TestCases table for h2o database!"

cursor.close()
h2o.close()

def create_accuracy_datasets(self):

#Connect to mysql database
h2o = mysql.connector.connect(user='root', password='0xdata', host='172.16.2.178', database='h2o')
cursor = h2o.cursor()

#Drop table first before creation
self.drop_acc_datasets_tables()

#Create accuracy datasets table to be imputed into h2o database
try:
acc_data_query = """
CREATE TABLE IF NOT EXISTS AccuracyDatasets(
data_set_id int(100) NOT NULL AUTO_INCREMENT,
uri varchar(100) NOT NULL,
respose_col_idx int(100) NOT NULL,
PRIMARY KEY (`data_set_id`)
)"""

cursor.execute(acc_data_query)
except:
traceback.print_exc()
h2o.rollback()
assert False, "Failed to build AccuracyDatasets table for h2o database!"

cursor.close()
h2o.close()

if __name__ == '__main__':
CreateMysqlTables().create_testcases_table()
CreateMysqlTables().create_accuracy_datasets()

0 comments on commit 1e8f2d1

Please sign in to comment.