A Python script may be used to connect to TDV (TIBCO Data Virtualization) using an ODBC DSN created on Windows. The steps are below.
1. If a TDV ODBC driver is not already installed on the Window box, install the ODBC driver.
The latest driver may be downloaded from https://edelivery.tibco.com/
2. Use the
Microsoft ODBC Manager to create a systems DSN, for example
TDV_DSN1.
3. Decide on a published resource that the Python script will query.
For example, the screenshot below shows a published resource named
ViewOrder.
4. Create a Python script, as shown in the example below.
test.py import pyodbc
conn = pyodbc.connect('dsn=' + "
TDV_DSN1")
conn.setdecoding(pyodbc.SQL_CHAR, encoding='utf-8')
conn.setencoding(encoding='utf-8')
sql = "
select * from ViewOrder"
cur = conn.cursor().execute(sql)
for row in cur:
print(row)
The script does the following:
- Reads the DSN to obtain the TDV ODBC driver location and the TDV server connection details.
- Opens a connection.
- Runs a SQL query on the published resource.
Output of the script: