예제 #1
0
 def __init__(self, engine_name):
     engine_name = engine_name
     
     default_connection = get_default_connection()
     if default_connection:
         parameters = get_saved_connection(default_connection)
         parameters["engine"] = default_connection
         engine = choose_engine(parameters)
     else:
         print " APPRUNNER 1"
     try:
         engine.get_connection()
     except:
         pass
예제 #2
0
def main():
    """
    main function the weaver module
    """

    # if no command line args are passed, launch GUI
    if len(sys.argv) == 1 :
        print "arguments required, use weaver -h for help"
        sys.exit(1)
   
    else:
        args = parser.parse_args()

        if args.quiet:
            sys.stdout = open(os.devnull, 'w')

        if args.command == 'help':
            parser.parse_args(['-h'])
            return
        if args.command == "weaver-gui":
            # launch GUI
            from weaver.app.main import launch_app
            launch_app()
        if args.command == 'citation':
            if args.dataset is None:
                # get the citation of weaver
                print("ToDos::citation of weaver")
                return
            else:
                print("ToDos::the citation for dataset "+args.dataset )

        # list the data sets available
        if args.command == 'ls':
            print("ToDos:: list of all available data sets.\n "
                  "Either we search the default retriever data folder")
            return

        # process single file to trim attributes
        if args.command == 'trim':
            print("ToDos:: project only the selected attributes")
            print(args.command + " data set to trim "+args.source_file+" result data set "+args.dest_file )
            print("attributes:")
            print (args.attr)
            return

        # basing on the database system used (engine)
        # delete comment : We assume that a person either uses mysql or postgres

        if args.command == 'dbjoin':
            # read config file.
            # if engines are present
            #
            # check if config and check the engines in the config file
            # query = read_config()
            # query = use_on_clause()

            from weaver.lib.tools import choose_engine
            engine = choose_engine(args.__dict__)

            # give the main Engine or its children a connection and session value
            engine_sqlarchemy = engine.db_connect()  # this returns create_engine of sqlarchemy

            # use the engine to create the sql statement from the config file.

            cconnection = engine_sqlarchemy.connect()

            query = engine.create_query()

            # todos check if query fields contain keywords
            result = cconnection.execute(query)
            print query
            for row in result:

                print row

            cconnection.close()




            pass