Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting list of odbc drivers available in windows 7 using python

I am trying to write a generic database connector class in python. For this I want to first check what drivers are installed on the machine and throw an error if the required drivers are missing in the machine.

Is there a way to do this in python?

like image 937
haraprasadj Avatar asked Nov 03 '14 10:11

haraprasadj


People also ask

How can I tell what ODBC Drivers are installed?

Open the Windows Control Panel. Open the Administrative Tools folder. Double-click Data Sources (ODBC) to open the ODBC Data Source Administrator window. Click the Drivers tab and locate the SQL Server entry in the list of ODBC drivers to confirm that the driver is installed on your system.

What is PDBC in Python?

pyodbc is an open source Python module that provides access to ODBC databases. pyodbc implements the Python DB API 2.0 specification. The Python DB API defines a database-neutral interface to data stored in relational databases.


1 Answers

pyodbc has a method which returns a list of installed ODBC drivers. Granted, it's just a list of the driver names, so it's a bit fiddly getting to the most current driver, but hopefully this will help.

I use regex (via the built-in re module) to filter down to the driver I need.

import pyodbc
pyodbc.drivers()

The output provides a list of installed ODBC drivers.

like image 171
S3DEV Avatar answered Sep 28 '22 10:09

S3DEV