odbc dsn

Manuel Ruiz mruiz at safa.es
Thu Jan 16 16:46:45 CET 2003


On Thu, 16 Jan 2003 15:18:48 GMT, mruiz at safa.es (Manuel Ruiz) wrote:

I hope this will be useful to someone !!

import _winreg

def getOdbcDsnList():

	try:
		reg = _winreg.ConnectRegistry( None,
_winreg.HKEY_LOCAL_MACHINE )
		subkey = _winreg.OpenKey( reg,
r'SOFTWARE\ODBC\ODBC.INI\ODBC DATA SOURCES' )

		dsn = []
		kinfo = _winreg.QueryInfoKey(subkey)

		for i in range(0, kinfo[1]):
			dsn.append( _winreg.EnumValue(subkey,i)[0] )

		_winreg.CloseKey(subkey)
		_winreg.CloseKey( reg )
	except Exception, e:
		lista = []

	return dsn

>
>Anyone could tell me how I could get a list of odbc dsn.
>
>Thanks in advance
>Manuel Ruiz
>





More information about the Python-list mailing list