Python embebbed with Oracle SQL*Plus

James T. Dennis jadestar at idiom.com
Thu Jun 28 06:31:01 CEST 2001


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()?).

> Also I have seen that that there is a special Perl 
> version for Oracle.  Is there something similar for 
> Python (and would it be necessary to make a special 
> Python for this?).

	The old "oraperl" was made obsolete (long ago)
	with the DBI interface and modules.  In Perl
	you have DBI which provides one abstract interface 
	to all SQL-like (and some non-SQL) databases
	(or things that you treat like databases in PERL)
	Then you have various DBDs which are called to 
	translate the DBI abstract functions/methods into
	the appropriate protocol/API for your database
	system.

> Generally, what is the best way to script Oracle with 
> Python, and how does it compare to the two above?

	There is a similar set of classes/modules for
	Python (import db?).  I'll let someone else 
	speak to the current state of those.  (I've
	used one of them to access a PostgreSQL system)
	It seems that there were a few of them competing
	at that time; and there was some sort of 
	standardization and implementation effort going on
	(which might have happened in Python 2.x or 2.1.x
	--- I don't know).



> Thanks
> Olav



More information about the Python-list mailing list