Db2

 View Only
  • 1.  How to use R with Db2 warehouse

    Posted Wed November 16, 2022 11:32 AM
    Hi guys, I really need your help because I just can't get ahead. I need Db2 Warehouse in combination with R to execute an important R command. For this reason I created an IBM Academic Account and got 1200$ credit for Db2 Warehouse Cloud.

    I would like to open R in the IBM Cloud browser window and then install this package in R ('ibmdbR'). Unfortunately, I have absolutely no idea how to proceed now.
    1) I neither know how to use R in Db2 Warehouse on Cloud nor how to get there?
    2) What all do I need to set up for this?

    Sorry, but I'm really a total noob. I haven't done anything in IBM Cloud yet and haven't changed anything in the settings. Please help me to be able to run this R package successfully (https://www.ibm.com/docs/en/ias?topic=packages-ibmdbr-package).

    Thank you

    ------------------------------
    Lorenz Wagner
    ------------------------------

    #Db2


  • 2.  RE: How to use R with Db2 warehouse

    Posted Fri November 18, 2022 01:12 PM
    Dear Lorenz,

    Lacking experience with the cloud environment I'm not able to guide you trough the entire process. 
    Instead let me give you a few hints how to proceed. 

    If you can already start an R console, the installation of the ibmdbR package is particularly simple.

    Just issue the command  install.packages("ibmdbR", dep=T) on the console command line. 
    With dep=T you make sure that prerequisite packages are loaded as well (there is at least one such package).

    Unlike with Db2 clients it is convenient in the R world to connect to the database via ODBC (rather than JDBC), so, you will have to condigure an ODBC connection.  
    This is the part I cannot guide you with in the cloud.
    At least you will have to declare an ODBC source, which in turn means you have 
    - to provide an ODBC driver
    - know the connecton parameters of your database (host or IP + port + name of the database)

    Once you managed to set up the ODBC source, there is a good tutorial on how to use the ibmdbP package:

    https://cran.r-project.org/web/packages/ibmdbR/vignettes/ibmdbR.pdf

    Before you can start the tutorial, please type library(ibdbR) on the R console command line to load the library into your R workspace.

    If you are not only interested to use the Db2 machine learning algorithms in R I find two sources fairly useful.

    The IBM Db2 document pages on the topic of machine learning:

    https://www.ibm.com/docs/en/db2/11.5?topic=content-in-database-machine-learning

    A non-IBM tutorial on how to use the IDAX functions in the  Db2 Warehouse :

    https://towardsdatascience.com/data-mining-in-db2-warehouse-the-basics-7b0b4fdcb736

    Hope this helps. 

    If you have trouble setting up the ODBC source in the cloud environment, maybe another friend can help.
    In this case  you may find it useful to post a second request with a specific subject line "Setting up a Db2 ODBC source in the cloud".

    Good luck, 

    Uli

    ------------------------------
    Uli Scharffenberger
    Information Architect
    IBM Germany
    ------------------------------



  • 3.  RE: How to use R with Db2 warehouse

    Posted Fri November 18, 2022 03:37 PM
    Related to Uli's above reply, another tutorial for creating ML models inside Db2 Warehouse is here: https://medium.com/ibm-data-ai/how-to-build-an-in-database-linear-regression-model-with-ibm-db2-b8f01af6a43
    Lorenz, just curious: what is your use case?

    ------------------------------
    SHAIKH Quader
    ------------------------------