Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van Rossum and first released in 1991. pyodbc is an open source Python module that makes accessing ODBC databases simple. It implements the DB API 2.0 specification.
This tutorial shows Python 3.6.1 and pyodbc working with the 64-bit Progress DataDirect Connect64 for ODBC Oracle Wire Protocol driver. The same steps are applicable to other ODBC drivers available from Progress Software.
Install and Configure the Driver
Install Python and pyodbc
Python Code Sample
Run the below code from the Python prompt or save the code to a .py file and then execute the file. The code sample has been attached to this tutorial as a plain text file.
Ensure that you have all the required environment variables set as per step 3 in "Install and Configure the Driver" above.
The Python code sample demonstrates connecting to Oracle using the Python ODBC interface using the Progress DataDirect Connect64 for ODBC Oracle Wire Protocol driver.
The code uses a data source named “SQLS” from the odbc.ini file to connect and issue a query. It creates a table, inserts data using literal and parameterized statements and fetches the data.
When running the sample code (above, and attached) at the Python terminal, output will be the following:
When running the same sample code from a file, the output will be the following:
The code can be modified to pass a connection string instead of using a data source to the pyodbc.connect() function for DSN-less connections.
While this tutorial demonstrates Python and pyodbc working with the 64-bit Progress DataDirect Connect64 for ODBC Oracle Wire Protocol driver, the same steps are applicable to other ODBC drivers available from Progress Software.
Note that we recommend and require use of the Progress ODBC driver manager, which is shipped with the Progress ODBC drivers. Progress DataDirect ODBC drivers are not certified with the unixODBC Driver Manager and reported issues must be reproducible with a supported version of the DataDirect ODBC Driver Manager for Unix/Linux.
Learn more and get started today with a free 15 day evaluation of Progress ODBC drivers
, available for many different data sources.