Commit 3d3e41b8 authored by Thomas Huetter's avatar Thomas Huetter

db service option for statistic script

parent cbba5a23
......@@ -19,9 +19,9 @@ import psycopg2
from psycopg2 import sql
# http://initd.org/psycopg/docs/sql.html#module-psycopg2.sql
def store_result(table_name, values_dict):
def store_result(service, table_name, values_dict):
# Connect to database.
db = psycopg2.connect("service=ted-join")
db = psycopg2.connect("service=" + service)
# Open a cursor to perform database operations
cur = db.cursor()
attributes = values_dict.keys()
......@@ -41,14 +41,14 @@ def store_result(table_name, values_dict):
# parse input argurments
parser = argparse.ArgumentParser()
parser.add_argument("--inputfile", type=str,
parser.add_argument("--inputfile", type=str, required=True,
help="path to input files containing line seperated trees in bracket notation")
parser.add_argument("--shortdesc", type=str, default="no description",
help="short description about the dataset")
parser.add_argument("--printlabels", action='store_true', dest='printlabels',
help="print label distribution")
parser.add_argument("--storeindb", action='store_true', dest='storeindb',
help="store the information about the dataset in a database")
parser.add_argument('--service', type=str,
help="Service name for db connection. Specify this parameter to store the results in a database.")
args = parser.parse_args()
......@@ -99,8 +99,8 @@ dataset_info += "}"
print(dataset_info)
# store dataset in db
if args.storeindb:
store_result(db_table_name, json.loads(dataset_info))
if args.service:
store_result(args.service, db_table_name, json.loads(dataset_info))
# print label distribution
if args.printlabels:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment