plpython function with dictionary as function argument?

Started by Gerardo Herzigover 20 years ago2 messagesgeneral
Jump to latest
#1Gerardo Herzig
gherzig@fmed.uba.ar

Hi all. I need to know if it is possible to call a plpython stored funcion
with an dictionary as single argument:

Suppose this python structure:

someDict = {
'field1': 'Foo',
'creepyfield': 'Bar'
}

The data base connection
CONN = pg.connect()....

I want some pypgslq function

CREATE myfunction ( __dictionary__) returns void
AS
.... (process)
LANGUAGE pythonu

and (the desired goal) be able to execute
CONN.execute("select * from myfunction (someDict)")

It this possible?

Thanks!!
--
Gerardo Herzig
Direccion General de Organizacion y Sistemas
Facultad de Medicina
U.B.A.

#2Peter Fein
pfein@pobox.com
In reply to: Gerardo Herzig (#1)
Re: plpython function with dictionary as function argument?

gherzig@fmed.uba.ar wrote:

Hi all. I need to know if it is possible to call a plpython stored funcion
with an dictionary as single argument:

Suppose this python structure:

someDict = {
'field1': 'Foo',
'creepyfield': 'Bar'
}

The data base connection
CONN = pg.connect()....

I want some pypgslq function

CREATE myfunction ( __dictionary__) returns void
AS
.... (process)
LANGUAGE pythonu

and (the desired goal) be able to execute
CONN.execute("select * from myfunction (someDict)")

Marshal someDict and unmarshal it in your function. Marshal is *very* fast.

--
Peter Fein pfein@pobox.com 773-575-0694

Basically, if you're not a utopianist, you're a schmuck. -J. Feldman