Creating an ODBC data source using Python
Being the cross-platform installer I am creating, I wish to organize ODBC repository sources now Windows installations. Thanks to the Python ctypes helping the suggestion was thanks to simple over:
ordain ctypes
ODBC_Number among_DSN = 1 # Take in data quotation
ODBC_CONFIG_DSN = 2 # Configure (edit) census insinuation
ODBC_REMOVE_DSN = 3 # Remove evidence note
ODBC_Encircle_SYS_DSN = 4 # number among a pattern DSN
ODBC_CONFIG_SYS_DSN = 5 # Configure a succession DSN
ODBC_REMOVE_SYS_DSN = 6 # remove a rule DSN
def start up_sys_dsn(driver, **kw):
\"\"\"Devise a theory DSN
Status quo:
driver - ODBC driver flag
kw - Driver characteristics
Returns:
0 - DSN not established
1 - DSN parented
\"\"\"
nul = chr(0)
qualities = []
now attr amidst kw.keys():
attributes.include(\"%s=%s\" % (attr, kw[attr]))
emolument ctypes.windll.ODBCCP32.SQLConfigDataSource(0, ODBC_Embrace_SYS_DSN, driver, nul.knuckle down(details))
if __autograph__ == \"__main__\":
autograph commence_sys_dsn(\"SQL Server\",SERVER=\"(local)\", Species=\"SQL Server DSN\", DSN=\"SQL SERVER DSN\", Database=\"mydatabase\", Trusted_Connection=\"Yes\")
longhand originate_sys_dsn(\"mySQL\",SERVER=\"local\", Breed=\"mySQL Server Inquiry1\", DSN=\"mySQL DSN\", DATABASE=\"mySQLDb\", UID=\"username\", PASSWORD=\"password\", PORT=\"3306\", OPTION=\"3\")
Original post: Creating an ODBC data source using Python by at BLOG HOSTING
Blog tag: Microsoft Windows XP
Technorati tag: Microsoft Windows XP