I'm trying to analyze my datasets on DB2 on Cloud in the Jupyter notebook created in Watson Studio. When using the "%sql" magic for connecting DB2 doesn't work naturally, showing no such module. According to an IBM tutorial, it is required to run the "%run db2re.ipynb" command in a Jupyter cell before connecting DB2. But when I run this cell nothing happens and the "%sql" magic still not available. Any advise is appreciated.
Asked
Active
Viewed 670 times
0
-
To which tutorial are you referring? – data_henrik Oct 24 '18 at 07:26
-
@data_henrik https://www.youtube.com/watch?v=bNfH0Wzx3is – Spring Oct 24 '18 at 07:47
-
Do you have that "db2re.ipynb" installed in your Watson Studio environment? – data_henrik Oct 24 '18 at 08:01
-
BTW: You can use that specific Db2 sql magic or this more general one: https://github.com/catherinedevlin/ipython-sql – data_henrik Oct 24 '18 at 08:04
-
@data_henrik Hi there, I'm not sure how to install it to my environment. I have it uploaded to the "Asset". – Spring Oct 24 '18 at 08:05
1 Answers
2
In general, there are two ways of accessing libraries in Watson Studio:
- Install or import a library, then reference it. Note that you need to specify the --user
option.
- First save your own scripts, then import them.
There are also the built-in line and cell magics. With that, I think I got it to work the following way:
1st cell, download db2re.ipynb to your environment:
%%sh
wget https://raw.githubusercontent.com/DB2-Samples/Db2re/master/db2re.ipynb
2nd cell, install necessary library:
!pip install --user qgrid
3rd cell, run the db2re.ipynb notebook extension:
%run db2re.ipynb
Thereafter, I was able to run a %sql
command.

data_henrik
- 16,724
- 2
- 28
- 49