anthony-tuininga / ceODBC

Python module for accessing databases using the ODBC API.
https://anthony-tuininga.github.io/ceODBC/
12 stars 8 forks source link

list of available datasources with ceODBC #8

Closed stonebig closed 1 year ago

stonebig commented 3 years ago

hello,

is there a way to get the list of available datasources with ceODBC ?

otherwise something like this would be nice to have:

sources = ceODBC.dataSources()
dsns = list(sources.keys())
sl = ['    %s [%s]' % (dsn, sources[dsn]) for dsn in dsns]
anthony-tuininga commented 3 years ago

I've just added support to get the list of data sources and also added support to get the list of drivers. This looks as follows:

sl = ['    %s [%s]' % d for d in ceODBC.data_sources()]

ceODBC.data_sources() returns a list of 2-tuples containing the DSN name and a description. You can exclude user DSNs or system DSNs as desired.

ceODBC.drivers() returns a list of strings containing the names of all the configured drivers.

Let me know if this works for you!

anthony-tuininga commented 1 year ago

3.1 was just released which includes this support.