SQLFlow is currently under active development. For those who are interested in trying it out, we have provided several demos. Play around with it. Any bug report and issue are welcomed. :)
- Install Docker.
- Set up a MySQL server following example/datasets/README.md.
- Pull the latest SQLFlow Docker image:
docker pull sqlflow/sqlflow:latest
.
-
Start a Docker container that runs sqlflowserver and Jupyter Notebook
docker run --rm -it -p 8888:8888 sqlflow/sqlflow:latest \ bash -c "sqlflowserver --db_user root --db_password root --db_address host.docker.internal:3306 & SQLFLOW_SERVER=localhost:50051 jupyter notebook --ip=0.0.0.0 --port=8888 --allow-root"
If you are running MySQL on the localhost and you are using Docker for Mac, please be aware the option
--db_address host.docker.internal:3306
wherehost.docker.internal
translates to the host ip address as recommended here.If you are running MySQL on remote, please be aware that MySQL only allows connections from localhost by default. Fix can be found here.
-
Open a Web browser and direct to
localhost:8888
and input the token. Then you can create notebooks. In a cell, you should be able to type%%sqlflow select 1
-
Explore more examples at example.ipynb
- Start a Docker container that runs SQLFlow command line prompt.
docker run -it --rm --net=host sqlflow/sqlflow:latest demo \
--db_user root --db_password root --db_address host.docker.internal:3306
You should be able to see the following prompt.
sqlflow>
- Select data
sqlflow> select * from iris.train limit 2;
-----------------------------
+--------------+-------------+--------------+-------------+-------+
| SEPAL LENGTH | SEPAL WIDTH | PETAL LENGTH | PETAL WIDTH | CLASS |
+--------------+-------------+--------------+-------------+-------+
| 6.4 | 2.8 | 5.6 | 2.2 | 2 |
| 5 | 2.3 | 3.3 | 1 | 1 |
+--------------+-------------+--------------+-------------+-------+
- Train a Tensorflow DNNClassifier
sqlflow> SELECT *
FROM iris.train
TRAIN DNNClassifier
WITH n_classes = 3, hidden_units = [10, 20]
COLUMN sepal_length, sepal_width, petal_length, petal_width
LABEL class
INTO my_dnn_model;
-----------------------------
...
Training set accuracy: 0.96721
Done training
- Prediction using a trained model
sqlflow> SELECT *
FROM iris.test
predict iris.predict.class
USING my_dnn_model;
- Checkout prediction result
sqlflow> select * from iris.predict limit 10;