Re: Python embebbed with Oracle SQL*Plus

From: Olav <olavb_at_yahoo.com>
Date: Sun, 22 Jul 2001 06:53:42 GMT
Message-ID: <eef39a63.0106280338.2b8b6935_at_posting.google.com>


"James T. Dennis" <jadestar_at_idiom.com> wrote in message news:<9hebu5$12lo$1_at_news.idiom.com>...
> In comp.lang.python Olav <olavb_at_yahoo.com> wrote:
>
> > Some time ago I did some Oracle SQL*Plus on UNIX,
> > and I was able to write quite powerful scripts
> > embebbed in ksh (Korn Shell).
 

> > Is something similar possible with Python?
>
> I presume your ksh scripts were passing
> SQL code to an sql command (possibly in
> the form of "here" documents).
>
> For course you can build arbitrary commands
> in Python and invoke the system to execute
> them. (sys.system()?).

This is a very simple Cygwin/NT example:



[Quoted] PLUS33 scott/tiger_at_prod_sa <<EOF
select COU_NAME from M1_countries
/
quit
eof

So it is not simply building an SQL-string and calling some function.

[Quoted] [Quoted] It is really like SQL embedded in the script. There are also mechanism for passing variables back and forth. (I can easily write a script that takes a sql-statement as an arguments from the command line, something like osql select "*" from M1_countries)

[Quoted] Typically what I use it for is regression-testing. I pass arguments on the command line to the script, execute an SQL-statement and run the output through sort, grep, diff etc.

[Quoted] [Quoted] I guess the mechanism is to build a temporary file, and call sqlplus with this.

[Quoted] I think it might be more difficult with Python because it is actually precompiled and because there is no equivalent of pipes.

**
Olav Received on Sun Jul 22 2001 - 08:53:42 CEST

Original text of this message