Getting a list of odbc drivers available on Windows 7 using python

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

Is there a way to do this in python?

+5


source to share


2 answers


I realize this is a late answer ... but stumbled upon the answer myself; in case anyone else is looking for an answer.

pyodbc

has a method that returns a list of installed ODBC drivers. Of course, this is just a list of driver names, so it is a little awkward to match the most recent driver, but hopefully this helps.

I am using regex (via inline module re

) to filter out the driver I want.



import pyodbc
pyodbc.drivers()

      

The output provides a list of installed ODBC drivers.

+15


source


There is nothing built into Python that will allow you to do this, except perhaps to do something really ugly with ctypes and I'm not sure if that would work. However, you can probably do it with Tim Golden's wmi.py module.

I found examples of using WMI to find common drivers:



So you probably have to filter the list in some way.

+1


source







All Articles