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

Compliant Database DevOps and the role of DevSecOps DevOps is becoming the new normal in application development, and DevSecOps is now entering the picture. By balancing the desire to release code faster with the need for the same code to be secure, it addresses increasing demands for data privacy. But what about the database? How can databases be included in both DevOps and DevSecOps? What additional measures should be considered to achieve truly compliant database DevOps? This whitepaper provides a valuable insight. Get the whitepaper

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.

Compliant Database DevOps and the role of DevSecOps DevOps is becoming the new normal in application development, and DevSecOps is now entering the picture. By balancing the desire to release code faster with the need for the same code to be secure, it addresses increasing demands for data privacy. But what about the database? How can databases be included in both DevOps and DevSecOps? What additional measures should be considered to achieve truly compliant database DevOps? This whitepaper provides a valuable insight. Get the whitepaper

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

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}