Loading data from DashDB

You can load data from DashDB tables and views.

Prerequisites

  • Collect your database connection information:

    • JDBC URL
    • user name
    • password
    • source table or view name
    If your DashDB service instance was provisioned in Bluemix you can find the connectivity information in the _Service Credentials_ tab or in the _Connect_ tab the dashDB web console.
  • Import PixieDust and enable the Spark Job monitor


In [6]:
import pixiedust
pixiedust.enableJobMonitor()


Configure database connectivity

Customize this cell with your DashDB connection information.


In [4]:
# @hidden_cell
# Enter your DashDB JDBC URL (e.g. 'jdbc:db2://dashdb-entry-yp-dal00-00.services.dal.bluemix.net:50000/BLUDB')
jdbcurl = 'jdbc:db2://...'
# Enter your DashDB user name (e.g. 'dash0815')
user = '...'
# Enter your DashDB password (e.g. 'myvoiceismypassword')
password = '...'
# Enter your source table or view name (e.g. 'mytable')
table = '...'

Load data from table

Load the table or view into a Spark DataFrame.


In [8]:
# no changes are required to this cell
# obtain Spark SQL Context
sqlContext = SQLContext(sc)
# load data
props = {}
props['user'] = user
props['password'] = password
dashdb_data = sqlContext.read.jdbc(jdbcurl, table, properties=props)


Explore the loaded data using PixieDust


In [9]:
display(dashdb_data)


Hey, there's something awesome here! To see it, open this notebook outside GitHub, in a viewer like Jupyter
For information on how to load data from other sources refer to [these code snippets](https://apsportal.ibm.com/docs/content/analyze-data/python_load.html).