Ejemplo n.º 1
0
def main():
    args = parser.parse_args()

    client = Client(server_url=args.url, ca_crt=args.ca_crt)
    for sql in args.sql:
        print("executing: {}".format(sql))
        print(client.execute(sql))
Ejemplo n.º 2
0
class SqlFlowMagic(Magics):
    """
    Provides the `%%sqlflow` magic
    """
    def __init__(self, shell):
        super(SqlFlowMagic, self).__init__(shell)
        self.client = Client()

    @cell_magic('sqlflow')
    def execute(self, line, cell):
        """Runs SQL statement

        :param line: The line magic
        :type line: str.
        :param cell: The cell magic
        :type cell: str.

        Example:

        >>> %%sqlflow SELECT *
        ... FROM mytable

        >>> %%sqlflow SELECT *
        ... FROM iris.iris limit 1
        ... TRAIN DNNClassifier
        ... WITH
        ...   n_classes = 3,
        ...   hidden_units = [10, 10]
        ... COLUMN sepal_length, sepal_width, petal_length, petal_width
        ... LABEL class
        ... INTO my_dnn_model;

        """
        return self.client.execute('\n'.join([line, cell]))
Ejemplo n.º 3
0
def main():
    args = parser.parse_args()

    client = Client(server_url=args.url)
    for sql in args.sql:
        print("executing: {}".format(sql))
        for res in client.execute(sql):
            print(res)