コード例 #1
0
 def setUp(self):
     # read config file
     self.config_obj = setup_db.read_config('../../development.ini')
     self.connection_tuple = setup_db.connect(self.config_obj)
コード例 #2
0
# other database functions
import setup_db

if __name__ == "__main__":
    parser = argparse.ArgumentParser(description='load ott into postgres')
    parser.add_argument('configfile',
        help='path to the development.ini file'
        )
    parser.add_argument('files_dir',
        help='path to the directory holding the csv files'
        )
    args = parser.parse_args()

    try:
        # read config variables
        config_obj = setup_db.read_config(args.configfile)
        connection, cursor = setup_db.connect(config_obj)

        # import the csv files into the tables
        starttime = dt.datetime.now()
        print "Importing taxonomy files"

        fullpath = os.path.abspath(args.files_dir)
        # taxonomy: ott.csv
        ott_filename = os.path.join(fullpath,'ott.csv')
        TAXONOMYTABLE = config_obj.get('database_tables','otttable')
        setup_db.import_csv_file(connection,cursor,TAXONOMYTABLE,ott_filename)

        # synonyms: synonyms.csv
        synonym_filename = os.path.join(fullpath,'synonyms.csv')
        SYNONYMTABLE = config_obj.get('database_tables','synonymtable')