Re: [Zope] connet to MS-SQL database with ython script from with in zope
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. --Madhavi
----- Original Message ----- From: <mbagepll@memphis.edu> To: "Jim Washington" <jwashin@vt.edu>; <zope@zope.org> Sent: Monday, February 18, 2002 4:23 PM Subject: Re: [Zope] connet to MS-SQL database with ython script from with in zope
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.
I haven't followed the rest of this thread, so tell me if I'm way off the mark. I do this by having a ZSQL Method (say sqlMethod) that simply contains <dtml-var the_sql> and has one argument (the_sql). I then build my sql statement within my python script and execute it like, #generate the sql statement results = container.sqlMethod(the_sql=generated_sql) #do stuff with the results I think there's a howto on www.zope.org somewhere, and a few previous posts on this list too. Have a scout around. I'm sure there must be security issues to consider as well... hth tim
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>
participants (3)
-
Jim Penny -
mbagepll@memphis.edu -
Tim Hicks