Db2 Tools for z/OS

Db2 Tools for z/OS

Connect with Db2, Informix, Netezza, open source, and other data experts to gain value from your data, share insights, and solve problems.

 View Only

Data Virtualization Manager: Setup Python access to VTB in 10 minutes

By Xingyan Jiang posted 2 days ago

  

Many people have asked how to use Python to access mainframe data sources—especially VSAM or IMS data. There are various approaches (direct and indirect), one of the most efficient ways would be using use the Data Virtualization Manager (DVM) (Introduction to Data Virtualization Manager) ODBC driver to query in-place data in real time. This guide walks you through installing and configuring the DVM ODBC driver in under 10 minutes.

Step 1: Download the DVM ODBC Driver

Go to IBM Fix Central and download the latest DVM ODBC driver for your platform.

Supported platforms include Windows, RHEL, SLES, Ubuntu, zLinux, we take Windows for example.

   

Step 2: Install the ODBC Driver

Run the downloaded installer.

Follow the installation wizard to complete setup.

Step 3: Configure the ODBC Data Source

Press Windows + S, type ODBC, and launch ODBC Data Sources (64-bit) or (32-bit) as Administrator.

On the System DSN tab, click Add…, then select Data Virtualization Manager Driver 3.2 and click Finish.

In the setup dialog:

  • Data Source Name: choose any identifier (e.g. DVM_SSID)

  • Host: your DVM server hostname

  • Port: your DVM server port 

  • User ID and Password: your credentials

Click Test Connection to verify that settings are correct, then click OK.

Step 4: Install the Python Driver (pyodbc)

pip install pyodbc

Step 5: Query via DSN in Python

import pyodbc
conn = pyodbc.connect('DSN=AVZJ') 
cursor = conn.cursor()
cursor.execute("select * from DVSQL.STAFFVS limit 10") 
for rows in cursor:
            print(rows)

Alternative: Connect without a DSN, you can skip Step 3 DSN configuration by specifying the full connection string directly:

import pyodbc
conn = pyodbc.connect(
    'DRIVER={Data Virtualization Manager Driver 3.2};'
    'HOST=rs01.rocketsoftware.com;'
    'PORT=18666;'
    'SUBSYS=NONE;'
    'UID=your_userid;'
    'PWD=your_password;'
    'DBTY=DVS;'
)
cursor = conn.cursor()
cursor.execute("select * from DVSQL.STAFFVS limit 10") 
for rows in cursor:
            print(rows)

Results :

(7, 'SANDERS  ', 20, 'MGR  ', 7)
(6, 'PERNAL   ', 20, 'SALES', 8)
(8, 'MARENGHI ', 38, 'MGR  ', 5)
(7, "O'BRIEN  ", 38, 'SALES', 6)
(5, 'HANES    ', 15, 'MGR  ', 10)
(7, 'QUIGLEY  ', 38, 'SALES', 0)
(7, 'ROTHMAN  ', 15, 'SALES', 7)
(5, 'JAMES    ', 20, 'CLERK', 0)
(7, 'KOONITZ  ', 42, 'SALES', 6)
(5, 'PLOTZ    ', 42, 'MGR  ', 7)

To install ODBC docker file for zCX, see here.

#DVMz

#Db2Toolsforz/OS

#Python

#Driver

0 comments
12 views

Permalink