Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Using Db2 as a Cloud SQL Database With Python

DZone's Guide to

Using Db2 as a Cloud SQL Database With Python

Get a demonstration of how simple it is to create a SQL database-backed web application in IBM Cloud using the native Db2 API.

· Database Zone
Free Resource

Find out how Database DevOps helps your team deliver value quicker while keeping your data safe and your organization compliant. Align DevOps for your applications with DevOps for your SQL Server databases to discover the advantages of true Database DevOps, brought to you in partnership with Redgate

Load data into Db2 on Cloud

Over the summer, I learned that Python is at the top of the IEEE programming languages ranking. It is also my favorite language for quickly coding tools, web apps and analyzing data with notebooks (such as on IBM Data Science Experience). Did you know that IBM provides four different Db2 drivers for Python? These are:

  1. A driver with the native Db2 API.

  2. A driver that supports the official Python DBI (database interface).

  3. A driver for the popular SQLAlchemy Python SQL Toolkit.

  4. A driver for the Python-based Django web framework.

In an older article, I showed you how to use SQLAlchemy with Db2. Today, I am going to demonstrate you how simple it is to create a SQL database-backed web app in the IBM Cloud, utilizing the native Db2 API.

The app is based on the Flask web framework and provides access to city information. The data comes from GeoNames. After the data has been loaded into Db2, it is accessed by the app and displayed using a simple page template. Users can search via a form or directly access city information through static URIs.City Information
I put the source code and all required instructions into a GitHub repository. The included README takes you through all the steps from provisioning a Db2 database on the IBM Cloud to creating a table and loading data to how to deploy the app. Make sure to take a look at the (few!) comments in the files that provide additional insight.

You can find an extended version of the instructions as a tutorial in the docs for IBM Cloud.

I hope you enjoy it. If you have feedback, suggestions, or questions about this post, please reach out to me on Twitter (@data_henrik) or LinkedIn.

Align DevOps for your applications with DevOps for your SQL Server databases to increase speed of delivery and keep data safe. Discover true Database DevOps, brought to you in partnership with Redgate

Topics:
python ,db2 ,sql ,ibm cloud ,cloud database

Published at DZone with permission of Henrik Loeser. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}