# ----------------------------------------------------------------------------- # Name : odbc.py # Version : .0.1 # Description : registers an access database in ODBC for Windows # Requirements : Python 2.x or higher # ----------------------------------------------------------------------------- # Author : Scott Hathaway # Contact : slhath@home.com # http://members.home.net/slhath/ # ----------------------------------------------------------------------------- # Classes: n/a # ----------------------------------------------------------------------------- # Functions: n/a # ----------------------------------------------------------------------------- # Disclaimer: The following code is provided into the public domain. The # author shall not be responsible for any use or misuse of this # code. # ----------------------------------------------------------------------------- # Note: n/a # ----------------------------------------------------------------------------- import _winreg as w parentKey = w.OpenKey(w.HKEY_LOCAL_MACHINE,r'Software\ODBC\ODBC.INI',0,w.KEY_WRITE) newKey = w.CreateKey(parentKey,'tri2') w.SetValueEx(newKey,'DBQ',0,w.REG_SZ,r'c:\apache\htdocs\t2\mdb\Trinity.mdb') w.SetValueEx(newKey,'Driver',0,w.REG_SZ,r'c:\windows\system\odbcjt32.dll') w.SetValueEx(newKey,'DriverId',0,w.REG_DWORD,25) w.SetValueEx(newKey,'FIL',0,w.REG_SZ,'MS Access;') w.SetValueEx(newKey,'SafeTransactions',0,w.REG_DWORD,0) w.SetValueEx(newKey,'UID',0,w.REG_SZ,'') parentKey = w.OpenKey(w.HKEY_LOCAL_MACHINE,r'Software\ODBC\ODBC.INI\tri2',0,w.KEY_WRITE) newKey = w.CreateKey(parentKey,'Engines') parentKey = w.OpenKey(w.HKEY_LOCAL_MACHINE,r'Software\ODBC\ODBC.INI\tri2\Engines',0,w.KE Y_WRITE) newKey = w.CreateKey(parentKey,'Jet') w.SetValueEx(newKey,'ImplicitCommitSync',0,w.REG_SZ,'') w.SetValueEx(newKey,'MaxBufferSize',0,w.REG_DWORD,2048) w.SetValueEx(newKey,'PageTimeout',0,w.REG_DWORD,5) w.SetValueEx(newKey,'Threads',0,w.REG_DWORD,3) w.SetValueEx(newKey,'UserCommitSync',0,w.REG_SZ,'Yes') parentKey = w.OpenKey(w.HKEY_LOCAL_MACHINE,r'Software\ODBC\ODBC.INI\ODBC Data Sources',0,w.KEY_WRITE) w.SetValueEx(parentKey,'tri2',0,w.REG_SZ,'Microsoft Access Driver (*.mdb)')