|
1 | 1 | --- |
2 | | -title: Visualization Databend Data in Jupyter Notebook |
3 | | -sidebar_label: Jupyter |
| 2 | +title: Jupyter Notebook |
| 3 | +sidebar_label: Jupyter Notebook |
4 | 4 | description: |
5 | | - Visualization Databend data in Jupyter Notebook. |
| 5 | + Integrating Databend with Jupyter Notebook. |
6 | 6 | --- |
7 | 7 |
|
| 8 | +[Jupyter Notebook](https://jupyter.org) is a web-based interactive application that enables you to create notebook documents that feature live code, interactive plots, widgets, equations, images, etc., and share these documents easily. It is also quite versatile as it can support many programming languages via kernels such as Julia, Python, Ruby, Scala, Haskell, and R. |
8 | 9 |
|
9 | | -<p align="center"> |
10 | | -<img src="https://datafuse-1253727613.cos.ap-hongkong.myqcloud.com/integration/integration-jupyter-databend.png" width="550"/> |
11 | | -</p> |
| 10 | +With the SQLAlchemy library in Python, you can establish a connection to Databend within a Jupyter Notebook, allowing you to execute queries and visualize your data from Databend directly in the Notebook. |
12 | 11 |
|
13 | | -## What is [Jupyter Notebook](https://jupyter.org/)? |
| 12 | +## Tutorial: Integrate with Jupyter Notebook |
14 | 13 |
|
15 | | -The Jupyter Notebook is the original web application for creating and sharing computational documents. It offers a simple, streamlined, document-centric experience. |
| 14 | +In this tutorial, you will first deploy a local Databend instance and Jupyter Notebook, and then run a sample notebook to connect to your local Databend, as well as write and visualize data within the notebook. |
16 | 15 |
|
17 | | -## Jupyter |
| 16 | +Before you start, make sure you have completed the following tasks: |
18 | 17 |
|
19 | | -### Create a Databend User |
| 18 | +- You have [Python](https://www.python.org/) installed on your system. |
| 19 | +- Download the sample notebook [databend.ipynb](https://datafuse-1253727613.cos.ap-hongkong.myqcloud.com/integration/databend.ipynb) to a local folder. |
20 | 20 |
|
21 | | -Connect to Databend server with MySQL client: |
22 | | -```shell |
23 | | -mysql -h127.0.0.1 -uroot -P3307 |
24 | | -``` |
| 21 | +### Step 1. Deploy Databend |
25 | 22 |
|
26 | | -Create a user: |
27 | | -```sql |
28 | | -CREATE USER user1 IDENTIFIED BY 'abc123'; |
29 | | -``` |
| 23 | +1. Follow the [Deployment Guide](https://databend.rs/doc/deploy) to deploy a local Databend. |
| 24 | +2. Create a SQL user in Databend. You will use this account to connect to Databend in Jupyter Notebook. |
30 | 25 |
|
31 | | -Grant privileges for the user: |
32 | 26 | ```sql |
| 27 | +CREATE USER user1 IDENTIFIED BY 'abc123'; |
33 | 28 | GRANT ALL ON *.* TO user1; |
34 | 29 | ``` |
35 | 30 |
|
36 | | -See also [How To Create User](../../14-sql-commands/00-ddl/30-user/01-user-create-user.md). |
| 31 | +### Step 2. Deploy Jupyter Notebook |
37 | 32 |
|
38 | | -### Install Jupyter Python Package |
| 33 | +1. Install Jupyter Notebook with pip: |
39 | 34 |
|
40 | | -Jupyter: |
41 | 35 | ```shell |
42 | | -pip install jupyterlab |
43 | 36 | pip install notebook |
44 | 37 | ``` |
45 | 38 |
|
46 | | -Dependencies: |
| 39 | +2. Install dependencies with pip: |
| 40 | + |
47 | 41 | ```shell |
48 | 42 | pip install sqlalchemy |
49 | 43 | pip install pandas |
| 44 | +pip install pymysql |
50 | 45 | ``` |
51 | 46 |
|
52 | | -### Run Jupyter Notebook |
| 47 | +### Step 3. Run Sample Notebook |
| 48 | + |
| 49 | +1. Run the command below to start Jupyter Notebook: |
53 | 50 |
|
54 | | -Download [**databend.ipynb**](https://datafuse-1253727613.cos.ap-hongkong.myqcloud.com/integration/databend.ipynb), start the notebook: |
55 | 51 | ```shell |
56 | 52 | jupyter notebook |
57 | 53 | ``` |
58 | 54 |
|
59 | | -Run `databend.ipynb` step by step, the demo show: |
60 | | -<p align="center"> |
61 | | -<img src="https://datafuse-1253727613.cos.ap-hongkong.myqcloud.com/integration/integration-gui-jupyter.png"/> |
62 | | -</p> |
| 55 | + This will start up Jupyter and your default browser should start (or open a new tab) to the following URL: http://localhost:8888/tree |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +2. On the **Files** tab, navigate to the sample notebook you downloaded and open it. |
| 60 | + |
| 61 | +3. In the sample notebook, run the cells in order. By doing so, you create a table containing 5 rows in your local Databend, and visualize the data with a bar chart. |
| 62 | + |
| 63 | + |
0 commit comments