0

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.

data_henrik
  • 16,724
  • 2
  • 28
  • 49
Spring
  • 3
  • 2

1 Answers1

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 %sqlcommand.

data_henrik
  • 16,724
  • 2
  • 28
  • 49