Esempio 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))
Esempio n. 2
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)
Esempio n. 3
0
 def test_decode_time(self):
     any_message = Any()
     timestamp_message = Timestamp()
     timestamp_message.GetCurrentTime()
     any_message.Pack(timestamp_message)
     assert timestamp_message.ToDatetime() == Client._decode_any(
         any_message)
Esempio n. 4
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]))
Esempio n. 5
0
 def setUpClass(cls):
     # TODO: free port is better
     port = 8765
     cls.event = threading.Event()
     threading.Thread(target=_server, args=[port, cls.event]).start()
     # wait for start
     time.sleep(1)
     cls.client = Client("localhost:%d" % port)
 def setUpClass(cls):
     # TODO: free port is better
     port = 8765
     cls.server_url = "localhost:%d" % port
     cls.event = threading.Event()
     cls.tmp_ca_dir, cls.ca_crt, ca_key = generateTempCA()
     threading.Thread(target=_server, args=[port, cls.event, cls.ca_crt, ca_key]).start()
     # wait for start
     time.sleep(1)
     cls.client = Client(cls.server_url, cls.ca_crt)
 def test_decode_null(self):
     any_message = Any()
     null_message = pb.Row.Null()
     any_message.Pack(null_message)
     assert Client._decode_any(any_message) is None
Esempio n. 8
0
 def __init__(self, shell):
     super(SqlFlowMagic, self).__init__(shell)
     self.client = Client()