[DB-SIG] Could someone please write a Python DB Tutorial?

M.-A. Lemburg mal@lemburg.com
Thu, 23 Nov 2000 13:01:27 +0100


"Trawoeger, Andreas" wrote:
> 
> Hi!
> 
> I started with Python DB programming three days ago and finally succeeded in
> most of what I wanted to do, but I had a really hard time to get there.
> 
> My primary goal was to be able to access the SQL Database of our M$ System
> Management Server from my Linux box I'm using for network monitoring. At
> first I did thought this couldn't be too difficult. I just want to pass a
> small SELECT statement to the SQL-Server and process the result using Python
> on my Linux box.
> 
> So I started to read the Python Database API. Which gave me absolutely no
> clue how to do what I wanted to do. It is a precise description of all
> functions of the API, but that's it. I can give you a precise description of
> the most important verbs and nouns of the German language. You will still
> find yourself have a lot of troubles writing a sentence in German.
> 
> The most useful information I have found are the OdbcHints for PythonWin.
> Which helped me to understand the basic DB API calls and how to solve part
> of my problems on a NT box, but I hadthe additional problem of porting the
> script from NT to Linux.

The DB topic guide on python.org has some hints and tutorials
about how to use the DB API and there are also a few Python books
which contain chapters about this, e.g. the Python book about Win32
programming.
 
> That's the point where I really got stuck. There is no in depth
> documentation about how to use the DB API and only small hints about M$ SQL
> connection on Linux on the mxODBC Homepage. It took me a 15 hour working day
> including a nightly hacking session till 2am to solve my Linux -> NT
> connection problem using the EasySoft ODBC<->ODBC Gateway.

Was the problem related to mxODBC or EasySoft ? Have you read the
mxODBC Configuration Guide by Paul Boddie ?

> I also thing that I'm going to have a hard time to use more API calls then:
> connect, cursor, execute, fetchall.
> 
> So I would really like to ask you to write a short Tutorial. Giving a short
> overview about all the available modules and which module you can use for
> which purpose and a couple of examples how to use the Python DB API. (The
> simple tip: For M$ SQL use the EasySoft ODBC Gateway could have saved me 4
> hours of desperate Google searches).

How about writing down you experiences like Paul Boddie did and
putting the results up on the web somewhere ?! This will help
others configure Python database access more easily.

BTW, I'd suggest asking in a forum like this before taking off
into an uncertain direction. The subscribers on this list do
have a lot of experience and may well be able to point you
to a possible solution.

For the Linux -> MS SQL access I would have pointed you to the
OpenLink/Merant ODBC driver kits which should allow you to connect
from Linux to NT. Another possibility would have been to try to
use a Sybase ODBC driver for Linux -- MS SQL Server's wire protocol
is said to be compatible with Sybase's.

--
Marc-Andre Lemburg
______________________________________________________________________
Company:                                        http://www.egenix.com/
Consulting:                                    http://www.lemburg.com/
Python Pages:                           http://www.lemburg.com/python/