示例#1
0
def commit(ctx, msg, table_name, file_name, delimiters, header):
    begin = time.time()
    conn = DatabaseManager(ctx.obj)
    executor = Executor(ctx.obj)
    executor.exec_commit(msg, table_name, file_name, delimiters, header, conn)
    end = time.time()
    print "\nCommit Latency: %0.3f ms\n" % ((end - begin) * 1000.0)
def drop(ctx, dataset):
    if click.confirm('Are you sure you want to drop %s?' % dataset):
        try:
            conn = DatabaseManager(ctx.obj)
            click.echo("Dropping dataset [%s] ..." % dataset)
            executor = Executor(ctx.obj)
            executor.exec_drop(dataset, conn)
        except Exception as e:
            click.secho(str(e), fg='red')
示例#3
0
def checkout(ctx, dataset, vlist, to_table, to_file, delimiters, header,
             ignore):
    begin = time.time()
    conn = DatabaseManager(ctx.obj)
    executor = Executor(ctx.obj)
    executor.exec_checkout(dataset, vlist, to_table, to_file, delimiters,
                           header, ignore, conn)
    end = time.time()
    print "\nCheckout Latency: %0.3f ms\n" % ((end - begin) * 1000.0)
def init(ctx, input_file, dataset, table_name, schema):
    # TODO: add header support
    # By default, we connect to the database specified in the -config- command earlier

    # Two cases need to be taken care of:
    # 1.add version control on an outside file
    #    1.1 Load a csv or other format of the file into DB
    #    1.2 Schema
    # 2.add version control on a existing table in DB
    executor = Executor(ctx.obj)
    conn = DatabaseManager(ctx.obj)
    executor.exec_init(input_file, dataset, table_name, schema, conn)
    def parse(self, cmd_string, explain_btn):
        # Preserve the string in commit command
        cmd = shlex.split(cmd_string)
        executor = Executor(self.config, self.request)
        if cmd[0] != "orpheus" or len(cmd) < 2:
            raise CommandNotExistError(cmd)
            return
        action = cmd[1]
        if action == "run" and explain_btn:
            action = "explain"
        elif explain_btn:
            messages.error(
                self.request,
                "This command could not be executed by the \'Explain\' button")
            return None
        try:
            if action == "init":
                input_file, dataset, table_name, schema = self.__parse_init(
                    cmd)

                conn = DatabaseManager(self.config, self.request)
                executor.exec_init(input_file, dataset, table_name, schema,
                                   conn)

            elif action == "checkout":
                dataset, vlist, to_table, to_file, delimiters, header, ignore = self.__parse_checkout(
                    cmd)
                conn = DatabaseManager(self.config, self.request)
                executor.exec_checkout(dataset, vlist, to_table, to_file,
                                       delimiters, header, ignore, conn)

            elif action == "commit":
                message, table_name, file_name, delimiters, header = self.__parse_commit(
                    cmd)
                conn = DatabaseManager(self.config, self.request)
                parent_name, curt_vid, parent_list = executor.exec_commit(
                    message, table_name, file_name, delimiters, header, conn)

            elif action == "run":
                sql = self.__parse_run(cmd)
                conn = DatabaseManager(self.config, self.request)
                attr_names, transactions = executor.exec_run(sql, conn)
                table_list = []
                table_list.append((attr_names, transactions))
                return table_list
            elif action == "explain":
                sql = self.__parse_run(cmd)
                conn = DatabaseManager(self.config, self.request)
                return executor.exec_explain(sql, conn)
            elif action == "drop":
                dataset = self.__parse_drop(cmd)
                conn = DatabaseManager(self.config, self.request)
                executor.exec_drop(dataset, conn)

            elif action == "show":
                dataset = self.__parse_show(cmd)
                conn = DatabaseManager(self.config, self.request)
                return executor.exec_show(dataset, conn)
            elif action == "restore":
                conn = DatabaseManager(self.config, self.request)
                executor.exec_restore(conn)
            else:
                raise CommandNotExistError(cmd_string)
                return
        except Exception as e:
            messages.error(self.request, str(e))
        return None
def commit(ctx, msg, table_name, file_name, delimiters, header):

    conn = DatabaseManager(ctx.obj)
    executor = Executor(ctx.obj)
    executor.exec_commit(msg, table_name, file_name, delimiters, header, conn)
def checkout(ctx, dataset, vlist, to_table, to_file, delimiters, header,
             ignore):
    conn = DatabaseManager(ctx.obj)
    executor = Executor(ctx.obj)
    executor.exec_checkout(dataset, vlist, to_table, to_file, delimiters,
                           header, ignore, conn)