[Zope] connet to MS-SQL database with ython script from with in zope

Jim Penny jpenny@universal-fasteners.com
Mon, 18 Feb 2002 11:49:57 -0500


On Mon, Feb 18, 2002 at 10:23:29AM -0600, mbagepll@memphis.edu wrote:
> Hi Jim,
> 
> Thank you very much. But i want to use Python scripts to write the sql 
> queries and not ZSQL methods. I have my ZODBCA installed and have 
> created a obdc connection to the MS-SQL database. Can i use this (i 
> mean the connection object) some how in the python script and query the 
> database.

Short Answer:  Yes, you should be able to.

Medium Long Answer:  You need to understand the python database
interface:
http://www.python.org/topics/database/DatabaseAPI-2.0.html

Slightly longer answer:  You also need to understand how much session
creation costs.  This varies from server to server, and I do not use
this adaptor.  But, for some databases, it will be large, and you will
not get the session caching that ZSQL provides.

Even Longer Answer:  98% of the time, ZSQL is the right way to go.  You
get better safety at the cost of more complicated
marshalling/demarshalling.  Performance is hard to estimate in advance,
the ZSQL method has more work to do, but has had quite a bit of effort
put into it regrading caching issues:  I suspect that for most methods
it is a wash.  ZSQL debugging, absent complicated sql-group expressions
is far easier.  Don't avoid ZSQL methods just because they "feel" wrong!
At least, do both implementations and time them!

Jim Penny
> 
> --Madhavi

Content-Description: Card for <mbagepll@memphis.edu>