# ATP, APEX and Jupyter



Suppose you have setup the [ATP connection,](connect-to-atp) and you are getting ready to learn more about creating APEX applications&#x20;

If you remember from one of our previous tutorials, [Setup APEX on ATP](setup-apex),  we were given three choices of creating an application:

![](https://3964595292-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRFinYAjIA976nxMf0U%2F-MRH9yUPDrbKFEfk8bmz%2F-MRHAXOW_6eE8cxQom5n%2F22.png?alt=media\&token=ef7fb746-2f5a-477c-a0df-3e9d137cd06e)



For this tutorial, we will build a small example on how to create an application by adding pages to existing data ("New Application").

However, let's suppose we do not have the data on our side. That would imply we need to create a tablespace and populate it.&#x20;

One approach to implement this would be by connecting to ATP using Jupyter, and then creating and populating a tablespace with the help of python dataframes; once the tablespace is created, we can add it to our application.

### Prepare environment&#x20;

`1) Install Jupyter (Ubuntu version, because this environment is deployed on my WSL)`

```
apt install jupyter-notebook
```

`2) Start Jupyter (in my case, I am root) and make sure you have the required packages installed:`

```
root@isaacEXE:/home/ora# jupyter-notebook --allow-root
[W 2021-01-17 21:16:48.015 LabApp] 'allow_root' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2021-01-17 21:16:48.016 LabApp] 'allow_root' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[...]
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=c0f8eb5b3c8ba697ae6db1c0f8eb5b4c7ae6db1c0f8eb5
     or http://127.0.0.1:8888/?token=c0f8eb5bc8ba697ae6db1c0f8eb5b4c7ae6db1c0f8eb5
[...]
```

`Add one of those links into your browser, got to File>New File>Python3, and make sure you install the required packages, if not present:`

![](https://3964595292-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRFinYAjIA976nxMf0U%2F-MRHBrCR-nXiirH9rjKY%2F-MRHCc_gpuDKWJA7YKVI%2Fpackages.png?alt=media\&token=c70c34eb-531e-4d3b-8d61-b3d8df5584fc)

`3) Download the data set we will be using to create the tablespace,` [`iris.csv`](https://gist.githubusercontent.com/netj/8836201/raw/6f9306ad21398ea43cba4f7d537619d0e07d5ae3/iris.csv)`:`

```
root@isaacEXE:/home/ora#  wget https://gist.githubusercontent.com/netj/8836201/raw/6f9306ad21398ea43cba4f7d537619d0e07d5ae3/iris.csv
root@isaacEXE:/home/ora# ls iris*
iris.csv
```



`4) Import the python modules you have just checked:`

![](https://3964595292-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRFinYAjIA976nxMf0U%2F-MRHDcZMlIDdWtubBTLB%2F-MRHEDCYqKJO766XWDWI%2Fmodules.png?alt=media\&token=582ed8c4-6f30-4ecc-a781-ea243460b57c)

`5) Make sure you TNS_ADMIN environment is setup, if not, recheck` [`About tnsname.ora`](../connect-to-atp#about-tnsname-ora) `As a reminder, our TNS_ADMIN was setup under /home/oracky/wallet.`

`Next, start your sqlalchemy application by creating the engine. Provide the oracle APEX user - the user you have used for creating workspace, the password and the database along with its priority.`

![](https://3964595292-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRFinYAjIA976nxMf0U%2F-MRHFbKucYyg4x1AFqMu%2F-MRHIdMNnJ2YT3uOzAuE%2Fnew_zack.png?alt=media\&token=9427dea8-aff2-485a-91fd-a91e7bd4a216)

`6) Import the dataset iris.csv into your ATP, by using the python dataframes:`

![](https://3964595292-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRFinYAjIA976nxMf0U%2F-MRHFbKucYyg4x1AFqMu%2F-MRHJESQb-bBjwcTPxLH%2Fdataset.png?alt=media\&token=52d8e42c-a1c8-405e-858e-6e79f679e5ec)

`7) Create the new tablespace in ATP:`

![](https://3964595292-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRFinYAjIA976nxMf0U%2F-MRHFbKucYyg4x1AFqMu%2F-MRHJdSs5UJPWQwmEYLs%2Fnew.png?alt=media\&token=c4777a89-44a0-4286-b232-c5c53bc10a56)

`8) Check in SQL Developer is tablespace DATAJUPYTER is created. It should appear for user ZACK:`

![](https://3964595292-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRFinYAjIA976nxMf0U%2F-MRHJtJgeHRMBtFTkymR%2F-MRHKA18wlcuRJ0oUvpd%2Fzacky.png?alt=media\&token=c823bdb4-de29-4bda-ba79-0eb9db0d32de)

###

### Create application in APEX

`Now you are ready to go back to your APEX workspace.`

`1) After you select "New Application", you will be brought to a blueprint for creating an application: provide a name, and select "Add Page":`

![](https://3964595292-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRFinYAjIA976nxMf0U%2F-MRHJtJgeHRMBtFTkymR%2F-MRHLAFAH8mROyDEY-yl%2F1.png?alt=media\&token=f5ccd8bf-8774-4879-9f5f-cfa64e7f1197)

`2) Select "Chart"`

![](https://3964595292-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRFinYAjIA976nxMf0U%2F-MRHLgh9hfuU1qS-up-4%2F-MRHMRQPHWcsEzvB2Qpw%2F2_2.png?alt=media\&token=5f219fa3-676f-4fd2-99a3-4f26383d17df)

`... and then, provide the name of the tablespace created with Jupyter and two columns columns, along with a desired representation of the dashboard:`

![](https://3964595292-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRFinYAjIA976nxMf0U%2F-MRHLgh9hfuU1qS-up-4%2F-MRHMvdzKCyu1-ks7k4s%2F2_3.png?alt=media\&token=5d172681-56fc-4139-a3cb-3d6fd4cb6ed2)

`2) Provide a page name, in this example "datajupyterpage", and click on "Add Page". You will be brought back to your "Create an Application" page, only this time, the page that contains the data from the tablespace is shown:`

![](https://3964595292-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRFinYAjIA976nxMf0U%2F-MRHLgh9hfuU1qS-up-4%2F-MRHNN_Q_YvCzW2nw5s8%2F24.png?alt=media\&token=ea1e5512-9d0a-47d9-a305-f7161a4ebd0b)

&#x20;`3) Proceed by selecting "Check All" from Features, and click "Create Application" to start the creation.`

&#x20;`4) As soon as your application is created, you should notice a page as below. Proceed with "Run Application"`

![](https://3964595292-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRFinYAjIA976nxMf0U%2F-MRHLgh9hfuU1qS-up-4%2F-MRHNtZgS3cc0XzZhh2m%2F1_3.png?alt=media\&token=5212176d-0120-4a3e-a78d-622f55e704b1)

5\) Provide APEX credentials:

![](https://3964595292-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRFinYAjIA976nxMf0U%2F-MRHLgh9hfuU1qS-up-4%2F-MRHOK9S8LrPUZq4yth_%2F4.png?alt=media\&token=a87bcd91-d0f4-4f55-b6ff-d358d6308e10)

`6) You are now ready to access the page you have set-up earlier:`

![](https://3964595292-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRFinYAjIA976nxMf0U%2F-MRHLgh9hfuU1qS-up-4%2F-MRHOY1pk7tDojkSF4Cj%2F5.png?alt=media\&token=377b250c-e3ba-48d6-b4e2-81be37b68424)

`7) Click on it, and it will take you straight to the dashboard representation:`

![](https://3964595292-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MRFinYAjIA976nxMf0U%2F-MRHO_gRmNr_xjPIj9Dy%2F-MRHOqmnMT52rsPQlUDO%2F6.png?alt=media\&token=9cb0d684-d0ee-4f26-adfd-54de81a1cff4)



\[ ... still in progress ...] &#x20;
