[Tutor] help-Please help me to write ODBC connection application

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Thu Sep 2 07:58:41 CEST 2004



On Wed, 1 Sep 2004, General Electronics,Phaltan wrote:

> I have 'MYDATA' as DSN in my ODBC. How can i write code to read tables from
> this DSN.


Hi Arvind,


Wait, wait: you're using some terms that may not be familiar to folks here
on the Tutor list.  DSN...  ODBC...

    http://en.wikipedia.org/wiki/Database_Source_Name
    http://en.wikipedia.org/wiki/ODBC

So you have a Database Source Name, and you're trying to connect to an
ODBC database?  Ok, you may want to look at the 'mxODBC' third-party
module:

    http://www.egenix.com/files/python/mxODBC.html

The examples on that page shows how to start up a connection, given a DSN:

###
>>> import mx.ODBC.iODBC
>>> db = mx.ODBC.iODBC.DriverConnect('DSN=database;UID=user;PWD=passwd')
###

And by this time, we should have a 'db' connection that we can use to
start querying the database.


> I am not famiilier with Python code.

Hmmm.  That can be a problem.  Are you sure you want to tackle databases
before Python?

You may want to get familiar with some Python basics, because otherwise,
depending on your previous background, you're bound to run into issues
that have nothing to do with databases, but have more to do with how
Python works.

It sounds like you've had some programming experience already.  If that's
the case, we strongly recommend you look at the Official Tutorial at:

    http://www.python.org/doc/tut/

to at least get you up to speed quickly.  There are other guides in:

    http://www.python.org/topics/learn/

that may also be useful as reference material.


If you have more questions, please feel free to ask.  Good luck!



More information about the Tutor mailing list