def handle_query(self, query):
        run_n = re.match('run-([0-9]+) (.*)', query, re.DOTALL)
        save_csv = query.startswith("save-csv ")

        if self.cypher.is_a_write_query(query) and self.read_only:
            print("Query aborted. You are in read-only mode.")

        elif query in ["quit", "exit"]:
            raise Exception

        elif query == "help":
            print_help()

        elif query == "refresh":
            self.neo4j.refresh()

        elif query == "schema":
            self.neo4j.print_schema()

        elif query == "schema-indexes":
            self.neo4j.print_indexes()

        elif query == "schema-constraints":
            self.neo4j.print_constraints()

        elif query == "schema-labels":
            self.neo4j.print_labels()

        elif query == "schema-rels":
            self.neo4j.print_relationship_types()

        elif query.startswith("env"):
            if query == "env":
                for key, value in self.neo4j.parameters.items():
                    print("{0}={1}".format(key, value))
            else:
                key = query[3:]
                key = key.strip("'\"[]")
                value = self.neo4j.parameters.get(key)

                if value is not None:
                    print(value)

        elif query.startswith("export "):
            if "=" not in query:
                print("Set parameters with export key=value.")
            else:
                params = query.replace("export ", "").strip()
                key, value = params.split("=", 1)
                key = key.strip()
                value = value.strip()

                try:
                    value = eval(value)
                    self.neo4j.update_parameters(key, value)
                except Exception as e:
                    print(e)

        else:
            count = int(run_n.group(1)) if run_n else 1
            query = run_n.group(2) if run_n else query
            query = query[len("save-csv "):] if save_csv else query

            if count <= 0 or not query:
                raise Exception

            total_duration = 0
            index = 0

            while index < count:
                response = self.neo4j.cypher(query)

                headers = response["headers"]
                rows = response["rows"]
                duration = response["duration"]
                error = response["error"]
                profile = response.get("profile")

                if error is False:
                    print(pretty_table(headers, rows))

                    ms = "Run {}: {} ms\n".format(index + 1, duration) if run_n else "{} ms".format(duration)
                    print(ms)

                    if profile:
                        self.neo4j.print_profile(profile)

                    if save_csv:
                        self.write_to_csvfile(headers, rows)
                else:
                    print(error)

                if self.logfile:
                    self.write_to_logfile(query, response)

                total_duration += duration
                index += 1

            if run_n and error is False:
                print("Total duration: {} ms".format(total_duration))
dataset/ETHPy150Open nicolewhite/cycli/cycli/main.py/Cycli.handle_query/original