Installation

SQLFlow is currently under active development. For those who are interested in tryingit out, we have provided the instructions and demo. Play around with it. Any bug report and issue is welcome. :)

Preparation

  • Install Docker Community Edition on your Macbook.
  • Pull the latest SQLFlow “all-in-one” Docker image, which contains pre-built SQLFlowbinary, sample datasets (under example/datasets), and jupyter notebook.
  1. docker pull sqlflow/sqlflow:latest

Running Your First SQLFlow Query

  • Simply type the below command to start the service:
  1. docker run -it -p 8888:8888 sqlflow/sqlflow:latest
  • Open a web browser, go to localhost:8888 and paste the token output from Notebook command above. Select the “New” drop-down menu on the right side, and open the “Python 3” development environment in a new Notebook cell (also in a new tab). In the new cell, type in below SELECT statement to fetch 5 records from train table in Iris database.
  1. %%sqlflow
  2. select * from iris.train limit 5;
  • Now you’ve successfully tested SQLFlow installation and written some SQL from Jupyter Notebook. Just as shown in the Quick Overview, you can continue your SQLFlow journey in the command line setting. Also feel free to check out more SQLFlow examples if you are new to Jupyter Notebook.

Use Your Own Database

If you have your own database setup, below steps enables running a seperated containerthat runs SQLFlow server and Jupyter Notebook, which connects to your own database.

  • Follow steps in example/datasets to import sample data.

  • After data is popularized in MySQL, let’s test the installation by running a query in Jupyter Notebook. If you are using Docker for Linux, please change host.docker.internal:3306 to localhost:3306. If you are connecting to a remote database, please make sure to change host.docker.internal:3306 to the remote address.

  1. docker run -it -p 8888:8888 sqlflow/sqlflow:latest \
  2. bash -c "sqlflowserver --datasource='mysql://root:root@tcp(host.docker.internal:3306)/?maxAllowedPacket=0' &
  3. SQLFLOW_SERVER=localhost:50051 jupyter notebook --ip=0.0.0.0 --port=8888 --allow-root"

If you are using Docker for Mac, please be aware the option —database where host.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.