>> An example from my code, which returns a database connection: >> >> import pyodbc >> >> def connect_to_db2(): >> """ >> quick and dirty connect to db2 >> """ >> s='DRIVER={iSeries access ODBC Driver};SYSTEM=10.3.36.150;UID=%s;PWD=%s' >> return >> connect_to_db(connect_str=s%('myuser','mypassword'),autocommit=True) >> >> db=connect_to_db2() >> c=db.cursor() >> # >> # insert working code here >> # >> c.close() >> db.close() >> > > You will also want to define a system data source on the machine > your running the above code on, instead of passing the driver > details to the Windows ODBC Manager directly. This makes your > code both more portable and creates fewer issues with Windows > permission management.
I disagree with the "DSN is best" generalization. They both have their places, and it is up to the developer to chose which is best for a given situation. In the case of sample code being posted to a mail list, I think DSNs just confuse things, as where a DSNless connection string makes it clear exactly what options are being set. I will agree that for production code, DSNs have something to offer, but even then there are cases where they aren't needed. Carl K _______________________________________________ DB-SIG maillist - DB-SIG@python.org http://mail.python.org/mailman/listinfo/db-sig