Connecting Progress database using Linux ODBC drivers from Python script with pyodbc module - Forum - OpenEdge General - Progress Community

Connecting Progress database using Linux ODBC drivers from Python script with pyodbc module

 Forum

Connecting Progress database using Linux ODBC drivers from Python script with pyodbc module

This question is answered

I have downloaded and installed the PROGRESS_DATADIRECT_ODBC_OE_LINUX_64.tar.Z on my linux server with the help of documentation. I have created the odbc.ini file and exported it as mentioned in the documentation.

odbc.ini:

[ODBC Data Sources]
PROGRESSDB = PROGRESSDB Server

IANAAppCodePage=4
InstallDir=/localhome/USER1/Progress/DataDirect/Connect64_for_ODBC_71
Trace=0
TraceFile=odbctrace.out
TraceDll=/localhome/USER1/Progress/DataDirect/Connect64_for_ODBC_71/lib/ddtrc27.so

[PROGRESSDB]
Driver=/localhome/USER1/Progress/DataDirect/Connect64_for_ODBC_71/lib/ddoe27.so
ApplicationUsingThreads=1
AlternateServers=
ArraySize=50
ConnectionRetryCount=0
ConnectionRetryDelay=3
Database=DBNAME
DefaultIsolationLevel=1
DefaultLongDataBuffLen=2048
EnableTimestampWithTimezone=1
EncryptionMethod=0
FailoverMode=0
FailoverGranularity=0
FailoverPreconnect=0
HostName=PROGRESSDBSERVER
HostNameInCertificate=
LoadBalancing=0
LoadBalanceTimeout=0
LoginTimeout=15
LogonID=dbuser
Password=dbpwd
PortNumber=2501
QueryTimeout=0
ReportCodePageConversionErrors=0
StaticCursorLongColBuffLen=4096
TrustStore=
TrustStorePassword=
UseWideCharacterTypes=0
ValidateServerCertificate=1

When I ran the 

ODBCINI= /localhome/USER1/Progress/DataDirect/Connect64_for_ODBC_71/odbc.ini; export ODBCINI

I got below messages:


/localhome/USER1/Progress/DataDirect/Connect64_for_ODBC_71/odbc.ini: line 1: [ODBC: command not found
/localhome/USER1/Progress/DataDirect/Connect64_for_ODBC_71/odbc.ini: line 2: PROGRESSDB: command not found
/localhome/USER1/Progress/DataDirect/Connect64_for_ODBC_71/odbc.ini: line 8: [PROGRESSDB]: command not found

So I am not sure whether export command executed successfully or not.

Then I tried my sample python code:

#!/usr/bin/python3

import pypyodbc as pyodbc

cnxn = pyodbc.connect('DSN=PROGRESSDB;UID=dbuser;PWD=dbpwd')
cursor = cnxn.cursor()
cursor.execute("select Username from PUB.Client")
rows = cursor.fetchall()
for row in rows:
print(row.Username)

But I am getting below error:

File "/usr/lib/python3.4/site-packages/pypyodbc.py", line 2434, in __init__
self.connect(connectString, autocommit, ansi, timeout, unicode_results, readonly)
File "/usr/lib/python3.4/site-packages/pypyodbc.py", line 2483, in connect
check_success(self, ret)
File "/usr/lib/python3.4/site-packages/pypyodbc.py", line 988, in check_success
ctrl_err(SQL_HANDLE_DBC, ODBC_obj.dbc_h, ret, ODBC_obj.ansi)
File "/usr/lib/python3.4/site-packages/pypyodbc.py", line 964, in ctrl_err
raise Error(state,err_text)
pypyodbc.Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified')

Kindly suggest if I am missing anything....

Thanks in advance.

 

Verified Answer
  • No spaces before/after the = sign ...
     

    ODBCINI=/localhome/USER1/Progress/DataDirect/Connect64_for_ODBC_71/odbc.ini; export ODBCINI

     
     

All Replies
  • No spaces before/after the = sign ...
     

    ODBCINI=/localhome/USER1/Progress/DataDirect/Connect64_for_ODBC_71/odbc.ini; export ODBCINI