Re: [GENERAL] plpython timestamp without time zone, showing up as text instead of timestamp

2014-03-23 Thread Adrian Klaver
On 03/23/2014 09:47 AM, jared wrote: On Sun, Mar 23, 2014 at 12:11 PM, Adrian Klaver mailto:adrian.kla...@aklaver.com>> wrote: Intended: http://www.postgresql.org/__docs/9.3/interactive/plpython-__data.html FY

Re: [GENERAL] plpython timestamp without time zone, showing up as text instead of timestamp

2014-03-23 Thread jared
On Sun, Mar 23, 2014 at 12:11 PM, Adrian Klaver wrote: > > Intended: > > http://www.postgresql.org/docs/9.3/interactive/plpython-data.html > > FYI, it would be a good idea to include the Postgres version. plpython has > been undergoing a lot of changes recently, so it would help to peg where > you

Re: [GENERAL] plpython timestamp without time zone, showing up as text instead of timestamp

2014-03-23 Thread Adrian Klaver
On 03/23/2014 08:19 AM, jared wrote: My full function works fine as a standalone python script, but I was having trouble getting it to work in Posgres. Outside of Postgres it worked fine (because I was feeding in lists of dates to test on). The I did the script with psycopg2 calling in the belo

[GENERAL] plpython timestamp without time zone, showing up as text instead of timestamp

2014-03-23 Thread jared
My full function works fine as a standalone python script, but I was having trouble getting it to work in Posgres. Outside of Postgres it worked fine (because I was feeding in lists of dates to test on). The I did the script with psycopg2 calling in the below table and it worked fine. (in the do

Re: [GENERAL] PlPython with pyodbc error DLL load failed: A dynamic link library (DLL) initialization routine failed.

2013-09-27 Thread Adrian Klaver
On 09/27/2013 08:55 AM, tuanhoanganh wrote: I try install plpython on PostgreSQL 9.3, Ubuntu 12.04 64bit but it has error when CREATE EXTENSION plpython3u; 2013-09-27 22:09:26 ICT LOG: database system was shut down at 2013-09-27 22:09:20 ICT 2013-09-27 22:09:26 ICT LOG: database system is ready

Re: [GENERAL] PlPython with pyodbc error DLL load failed: A dynamic link library (DLL) initialization routine failed.

2013-09-27 Thread tuanhoanganh
I try install plpython on PostgreSQL 9.3, Ubuntu 12.04 64bit but it has error when CREATE EXTENSION plpython3u; 2013-09-27 22:09:26 ICT LOG: database system was shut down at 2013-09-27 22:09:20 ICT 2013-09-27 22:09:26 ICT LOG: database system is ready to accept connections 2013-09-27 22:09:26 ICT

Re: [GENERAL] PlPython with pyodbc error DLL load failed: A dynamic link library (DLL) initialization routine failed.

2013-09-26 Thread tuanhoanganh
If i run import pyodbc from python command and run pyodbc sql command, everything work well. Please help me. Tuan Hoang Anh On Fri, Sep 27, 2013 at 10:05 AM, John R Pierce wrote: > On 9/26/2013 8:00 PM, tuanhoanganh wrote: > >> >> I updated my laptop to windows 8.1, my PostgreSQL version is 9.

Re: [GENERAL] PlPython with pyodbc error DLL load failed: A dynamic link library (DLL) initialization routine failed.

2013-09-26 Thread John R Pierce
On 9/26/2013 8:00 PM, tuanhoanganh wrote: I updated my laptop to windows 8.1, my PostgreSQL version is 9.2.3 64 bit. But my plpython function have "ERROR: ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed." after import pyodbc My Python version is Active

[GENERAL] PlPython with pyodbc error DLL load failed: A dynamic link library (DLL) initialization routine failed.

2013-09-26 Thread tuanhoanganh
Hello all. I updated my laptop to windows 8.1, my PostgreSQL version is 9.2.3 64 bit. But my plpython function have "ERROR: ImportError: DLL load failed: A dynamic link library (DLL) initialization routine failed." after import pyodbc My Python version is ActivePython-3.2.2.3-win64-x64, pyodbc ver

Re: [GENERAL] plpython intermittent ImportErrors

2013-01-17 Thread Brian Sutherland
On Thu, Jan 17, 2013 at 01:25:54PM +0100, Alban Hertroys wrote: > On 17 January 2013 12:30, Brian Sutherland wrote: > > > > (we use buildout for our Python code, but our plpythonu stored > > > procedures use the stock standard Python environment, as provided by > > > the Ubuntu packages). > > > >

Re: [GENERAL] plpython intermittent ImportErrors

2013-01-17 Thread Alban Hertroys
On 17 January 2013 12:30, Brian Sutherland wrote: > > (we use buildout for our Python code, but our plpythonu stored > > procedures use the stock standard Python environment, as provided by > > the Ubuntu packages). > > Sadly, I need to get this running on OSX as that's what our developers > use.

Re: [GENERAL] plpython intermittent ImportErrors

2013-01-17 Thread Brian Sutherland
On Thu, Jan 17, 2013 at 03:18:09PM +0700, Stuart Bishop wrote: > On Mon, Jan 14, 2013 at 11:30 PM, Brian Sutherland > wrote: > > Hi, > > > > I have a plpython stored procedure which sometimes fails when I run my > > applications automated test suite. The procedure is called hundreds of > > times d

Re: [GENERAL] plpython intermittent ImportErrors

2013-01-17 Thread Stuart Bishop
On Mon, Jan 14, 2013 at 11:30 PM, Brian Sutherland wrote: > Hi, > > I have a plpython stored procedure which sometimes fails when I run my > applications automated test suite. The procedure is called hundreds of > times during the tests but only fails a few times, often with the > following Import

Re: [GENERAL] plpython intermittent ImportErrors RESOLVED

2013-01-16 Thread Adrian Klaver
On 01/16/2013 08:20 AM, Brian Sutherland wrote: On Mon, Jan 14, 2013 at 09:05:09AM -0800, Adrian Klaver wrote: On 01/14/2013 08:30 AM, Brian Sutherland wrote: I had a look at the files open by the process, there were not that many, so no leaks or anything. Just an utterly insane OSX default

Re: [GENERAL] plpython intermittent ImportErrors RESOLVED

2013-01-16 Thread Brian Sutherland
On Mon, Jan 14, 2013 at 09:05:09AM -0800, Adrian Klaver wrote: > On 01/14/2013 08:30 AM, Brian Sutherland wrote: > >Hi, > > > >I have a plpython stored procedure which sometimes fails when I run my > >applications automated test suite. The procedure is called hundreds of > >times during the tests b

Re: [GENERAL] plpython intermittent ImportErrors

2013-01-16 Thread Brian Sutherland
On Wed, Jan 16, 2013 at 08:10:26AM +1100, Chris Angelico wrote: > On Tue, Jan 15, 2013 at 4:55 AM, Brian Sutherland > wrote: > > I'm guessing that it's some kind of race condition, but I wouldn't know > > where to start looking. > > Look for a recursive import (A imports B, B imports A) I've al

Re: [GENERAL] plpython intermittent ImportErrors

2013-01-15 Thread Chris Angelico
On Tue, Jan 15, 2013 at 4:55 AM, Brian Sutherland wrote: > I'm guessing that it's some kind of race condition, but I wouldn't know > where to start looking. Look for a recursive import (A imports B, B imports A) or multiple threads trying to import simultaneously - Python sometimes has issues wit

Re: [GENERAL] plpython intermittent ImportErrors

2013-01-14 Thread Adrian Klaver
On 01/14/2013 09:55 AM, Brian Sutherland wrote: Changing the order in which the tests are run, or running tests individually makes the error move/change or disappear. The behaviour is the same with PostgreSQL versions 9.2.2 and 9.1.7. I have tried (but failed) to reproduce this error in a simp

Re: [GENERAL] plpython intermittent ImportErrors

2013-01-14 Thread Brian Sutherland
On Mon, Jan 14, 2013 at 09:05:09AM -0800, Adrian Klaver wrote: > On 01/14/2013 08:30 AM, Brian Sutherland wrote: > >Hi, > > > >I have a plpython stored procedure which sometimes fails when I run my > >applications automated test suite. The procedure is called hundreds of > >times during the tests b

Re: [GENERAL] plpython intermittent ImportErrors

2013-01-14 Thread Adrian Klaver
On 01/14/2013 08:30 AM, Brian Sutherland wrote: Hi, I have a plpython stored procedure which sometimes fails when I run my applications automated test suite. The procedure is called hundreds of times during the tests but only fails a few times, often with the following ImportError: Traceba

[GENERAL] plpython intermittent ImportErrors

2013-01-14 Thread Brian Sutherland
Hi, I have a plpython stored procedure which sometimes fails when I run my applications automated test suite. The procedure is called hundreds of times during the tests but only fails a few times, often with the following ImportError: Traceback (most recent call last): File "/Users/jint

[GENERAL] plpython on postgresql 9.1

2011-10-14 Thread Dario Beraldi
Hello, I have installed postgresql on a mac using the 'one click' installer (postgresql-9.1.1-1-osx.dmg). I then tried to import the python language but I get the error: create language plpythonu; ERROR: could not access file "$libdir/plpython2": No such file or directory Can you help me in fig

Re: [GENERAL] plpython module import errors

2011-04-28 Thread c k
Cheers! Solved. What I did is complied source with python option (it failed even giving correct python 3.2 as per instruction given in the manual page you have shown) for python 2.7. From build and installed postgresql, copied plpython2.so and plpython.so to the developement server and restarted it

Re: [GENERAL] plpython module import errors

2011-04-28 Thread c k
Now, I found that python version postresql is using is 2.6 and path to it is "['/home/apy/rrun/build/activepython-svn-trunk/build/py2_6_4-linux-x86-apy26-rrun/CoReAcTiVePyThOnPrEfIxCoReAcTiVePyThOnPrEfIxCoReAcTiVePyThOnPrEfIxCoReAcTiVePyThOnPrEfIxCoReAcTiVePyThOnPrEfIxCoReAcTiVePyThOnPrEfIxCoReAcT

Re: [GENERAL] plpython module import errors

2011-04-28 Thread Adrian Klaver
On Thursday, April 28, 2011 7:11:50 am c k wrote: > Yes, there are three version (now). I am aware of only 2.7 installed > by default in /usr/lib directory and 3.2 which I have installed > externally. But the function given above shows version 2.6.4. > Now the question is how to change the version

Re: [GENERAL] plpython module import errors

2011-04-28 Thread c k
Yes, there are three version (now). I am aware of only 2.7 installed by default in /usr/lib directory and 3.2 which I have installed externally. But the function given above shows version 2.6.4. Now the question is how to change the version postresql is calling for function execution? I have also c

Re: [GENERAL] plpython module import errors

2011-04-28 Thread Karsten Hilbert
On Thu, Apr 28, 2011 at 09:15:06AM -0400, Martin Gainty wrote: > mv python python5 (for python version 5 binary) > mv python python6 (for python version 6 binary) Do you happen to mean 2.5 and 2.6 ? Given that, say, our Electronic Medical Record solution happily runs on Python 2.5, 2.6, and 2.7

Re: [GENERAL] plpython module import errors

2011-04-28 Thread Martin Gainty
gmail.com > CC: pgsql-general@postgresql.org > Subject: Re: [GENERAL] plpython module import errors > > On 04/28/2011 02:19 PM, c k wrote: > > > Hello, > > I have installed postgresql 9 on fedora 14 having python 2.7. Now > > created plpythonu language in my

Re: [GENERAL] plpython module import errors

2011-04-28 Thread Sim Zacks
On 04/28/2011 02:19 PM, c k wrote: Hello, I have installed postgresql 9 on fedora 14 having python 2.7. Now created plpythonu language in my database and created a simple function to calculate sum of two variables. while importing math libbrary and executing the function i got the error PL/Pytho

[GENERAL] plpython module import errors

2011-04-28 Thread c k
Hello, I have installed postgresql 9 on fedora 14 having python 2.7. Now created plpythonu language in my database and created a simple function to calculate sum of two variables. while importing math libbrary and executing the function i got the error PL/Python: ImportError: No module named cmath

Re: [GENERAL] plpython returns integer[] fails for multi-dimensional array

2010-12-21 Thread TJ O'Donnell
In previous versions (8.x) for plpython fn returning integer[] I created (had to create) a string in the proper SQL format { {1,2,3}, {4,5,6} } and returned that. It worked fine. I LIKE the ability to not have to do that in 9.0 but I CAN'T return and string like { {1,2,3}, {4,5,6} } for a fn th

Re: [GENERAL] plpython returns integer[] fails for multi-dimensional array

2010-12-21 Thread Adrian Klaver
On Tuesday 21 December 2010 3:25:48 pm Peter Geoghegan wrote: > On 21 December 2010 23:17, Thom Brown wrote: > > Are you sure that "a" returns okay in that scenario. You're using a > > list. Shouldn't you be using an array? Like: a = [] > > a =[] actually declares an empty list in Python. You c

Re: [GENERAL] plpython returns integer[] fails for multi-dimensional array

2010-12-21 Thread Adrian Klaver
On Tuesday 21 December 2010 2:48:16 pm TJ O'Donnell wrote: > In postgresql-9.0.1 I have to modify my plpython functions that return > arrays. It seems one dimesional arrays are handled properly, but not > 2-dimensional arrays. > > create or replace function atest() returns integer[] as $eopy$ > a

Re: [GENERAL] plpython returns integer[] fails for multi-dimensional array

2010-12-21 Thread Peter Geoghegan
On 21 December 2010 23:17, Thom Brown wrote: > Are you sure that "a" returns okay in that scenario. You're using a > list. Shouldn't you be using an array? Like: a = [] a =[] actually declares an empty list in Python. You can return a list or a tuple from a pl/python function in 9.0 and it wil

Re: [GENERAL] plpython returns integer[] fails for multi-dimensional array

2010-12-21 Thread Thom Brown
On 21 December 2010 22:48, TJ O'Donnell wrote: > In postgresql-9.0.1 I have to modify my plpython functions that return arrays. > It seems one dimesional arrays are handled properly, but not > 2-dimensional arrays. > > create or replace function atest() returns integer[] as $eopy$ >  a = list() >

[GENERAL] plpython returns integer[] fails for multi-dimensional array

2010-12-21 Thread TJ O'Donnell
In postgresql-9.0.1 I have to modify my plpython functions that return arrays. It seems one dimesional arrays are handled properly, but not 2-dimensional arrays. create or replace function atest() returns integer[] as $eopy$ a = list() a.append(1) a.append(2) a.append(3) #return a works fine

Re: [GENERAL] plpython feature idea: an option to return row results as lists

2010-07-30 Thread Peter Eisentraut
On fre, 2010-07-30 at 16:45 -0500, Derek Arnold wrote: > Has there ever been any interest in adding a keyword option for > returning row lists rather than dicts? I don't think so, but it sounds like a reasonable idea. Other possible approaches are - Using a factory class like psycopg (http://in

Re: [GENERAL] plpython feature idea: an option to return row results as lists

2010-07-30 Thread Alex Hunsaker
On Fri, Jul 30, 2010 at 15:45, Derek Arnold wrote: > With result rows in plpython returned as dicts rather than lists, we ran > into issues with a need to preserve the column order in the resultset. Interesting, +1 for the idea. > plpy.execute(""" > SELECT 1 as a, 2 as b, NULL as c, ARRAY[1,2,

[GENERAL] plpython feature idea: an option to return row results as lists

2010-07-30 Thread Derek Arnold
With result rows in plpython returned as dicts rather than lists, we ran into issues with a need to preserve the column order in the resultset. Of course, dicts in python have an arbitrary, non-random order. It's consistent in the result but does not match the order in the query. Our use case w

Re: [GENERAL] plpython return setof and yield

2009-08-17 Thread Nuno Mota
Ok, now I think I understand since I already have a result set from the query I cannot use yield. The other example works because I am generating only one result set. On Mon, Aug 17, 2009 at 7:55 PM, Nuno Mota wrote: > I have fixed the problem populating a list and returning it. > > Well I gues

Re: [GENERAL] plpython return setof and yield

2009-08-17 Thread Nuno Mota
I have fixed the problem populating a list and returning it. Well I guess I have to learn a litte bit more of python to understand how to use yield when using multiple result sets. Thank you anyway On Mon, Aug 17, 2009 at 7:23 PM, Adrian Klaver wrote: > > > - "Nuno Mota" wrote: > > > Tha

Re: [GENERAL] plpython return setof and yield

2009-08-17 Thread Adrian Klaver
- "Nuno Mota" wrote: > Thank you very much, > > Can i ask one more question ? > > How do I declare the correct result set to return, this in first > example code, is it possible ? > > Thank you again, > Nuno Mota > > >From here: http://www.postgresql.org/docs/8.3/interactive/plpython-

Re: [GENERAL] plpython return setof and yield

2009-08-17 Thread Nuno Mota
Thank you very much, Can i ask one more question ? How do I declare the correct result set to return, this in first example code, is it possible ? Thank you again, Nuno Mota On Mon, Aug 17, 2009 at 3:21 PM, Adrian Klaver wrote: > On Sunday 16 August 2009 5:13:51 pm Nuno Mota wrote: > > Hi, >

Re: [GENERAL] plpython return setof and yield

2009-08-17 Thread Adrian Klaver
On Sunday 16 August 2009 5:13:51 pm Nuno Mota wrote: > Hi, > > I am kind of new into python, and I have been trying to port some plperl > functions into plpython, but I've run up into a problem. > > Imagine the following plpython code. > > CREATE OR REPLACE FUNCTION greet (how text) > RETURNS SET

[GENERAL] plpython return setof and yield

2009-08-16 Thread Nuno Mota
Hi, I am kind of new into python, and I have been trying to port some plperl functions into plpython, but I've run up into a problem. Imagine the following plpython code. CREATE OR REPLACE FUNCTION greet (how text) RETURNS SETOF greeting AS $$ rv = plpy.execute("SELECT 1") for article in

Re: [GENERAL] PLPython function and multiple line insert

2009-06-06 Thread Igor Katson
Andi Klapper wrote: sql = "("INSERT INTO table1 (field1, field2, field3) VALUES ('abc', 'abc', TRUE), ('def', 'def', FALSE), ('ghi', 'ghi', TRUE");" pypl.execute(sql) . . $$ LANGUAGE 'plpythonu' VOLATILE I ran into trouble with quoting this

[GENERAL] PLPython function and multiple line insert

2009-06-05 Thread Andi Klapper
Hi everyone, I hope, I am on the right list. If not my apology. I'd like to insert multiple lines as following with PLPython: SQL statement: INSET INTO table1 (field1, field2, field3) VALES ('abc', 'abc', TRUE), ('def', 'def', FALSE), ('ghi', 'ghi', TRUE);

[GENERAL] plpython large result set

2009-03-02 Thread K D
Hello, I am hoping to use plpython to perform various transforms on query results of very large size. The documentation in the official 8.3 manual makes it appear as if the results of plpy.execute are read in at once (e.g., they appear to have random access and are mutable) rather than in the hid

[GENERAL] plpython infinite loop

2009-01-27 Thread Sim Zacks
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I'm using posgresql 8.2.4 on Gentoo Linux. Is there anything that can be done about an infinite loop in plpython? I tired stopping the query (with PG Admin), but the process kept going on the server. I tried pg_cancel_backend but it kept running. I tr

Re: [GENERAL] plpython array support

2007-11-23 Thread Stuart Bishop
Sean Davis wrote: > On Nov 19, 2007 9:08 PM, Jorge Godoy <[EMAIL PROTECTED]> wrote: >> Em Monday 19 November 2007 19:29:51 Sean Davis escreveu: >>> Just a simple question--does plpythonu (8.3beta) have support for >>> arrays? I don't see a specific mention of it in the docs, so I >>> suppose not.

Re: [GENERAL] plpython array support

2007-11-19 Thread Sean Davis
On Nov 19, 2007 9:08 PM, Jorge Godoy <[EMAIL PROTECTED]> wrote: > Em Monday 19 November 2007 19:29:51 Sean Davis escreveu: > > Just a simple question--does plpythonu (8.3beta) have support for > > arrays? I don't see a specific mention of it in the docs, so I > > suppose not. > > Arrays work for a

Re: [GENERAL] plpython and error catching

2007-11-19 Thread Adrian Klaver
On Monday 19 November 2007 10:37 am, Sean Davis wrote: > What is the expected behavior of a construct like this: > > def insert_xml(elem): > id=int(elem.findtext('PMID')) > try: > plpy.execute(plan,[unicode(ET.tostring(elem)),id]) > except: > plpy.execute(plan2,[unicode(

Re: [GENERAL] plpython array support

2007-11-19 Thread Jorge Godoy
Em Monday 19 November 2007 19:29:51 Sean Davis escreveu: > Just a simple question--does plpythonu (8.3beta) have support for > arrays? I don't see a specific mention of it in the docs, so I > suppose not. Arrays work for a long time now. I've been using them since 8.1, for sure, but I think tha

[GENERAL] plpython array support

2007-11-19 Thread Sean Davis
Just a simple question--does plpythonu (8.3beta) have support for arrays? I don't see a specific mention of it in the docs, so I suppose not. Thanks, Sean ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://ww

[GENERAL] plpython and error catching

2007-11-19 Thread Sean Davis
What is the expected behavior of a construct like this: def insert_xml(elem): id=int(elem.findtext('PMID')) try: plpy.execute(plan,[unicode(ET.tostring(elem)),id]) except: plpy.execute(plan2,[unicode(ET.tostring(elem)),id]) id is a primary key on the table into which I

Re: [GENERAL] plpython

2006-10-27 Thread Clodoaldo Pinto Neto
2006/10/27, km <[EMAIL PROTECTED]>: i am stuck at createlang for plpythonu! with postgres user error reads: $createlang plpythonu template1; createlang: language installation failed: ERROR: could not load library "/usr/local/pgsql/lib/plpython.so": /usr/local/pgsql/lib/plpython.so: undefined

Re: [GENERAL] plpython

2006-10-27 Thread km
> Sure. But it depends a lot on what you're willing to do. The docs have the > details. This one I did just to learn it: > > CREATE FUNCTION f_v_fechamento(p_cliente_id integer, p_data date, p_pago > boolean, OUT retorno record) RETURNS record > AS $$ > p_cliente_id = args[0] > p_data = ar

Re: [GENERAL] plpython

2006-10-27 Thread Harald Armin Massa
KM,Can someone hint on resources for using plpython for writing stored procedures ? I have gone thru official docs for  8.1.5 for plpythonu but its not in detail/with examples.CREATE OR REPLACE FUNCTION myfunc(text)  RETURNS text AS$BODY$eingabe=args[0]hello = "Good Morning %s" % (eingabe,) return

Re: [GENERAL] plpython

2006-10-27 Thread Jorge Godoy
km <[EMAIL PROTECTED]> writes: > Can someone hint on resources for using plpython for writing stored > procedures ? Sure. But it depends a lot on what you're willing to do. The docs have the details. This one I did just to learn it: CREATE FUNCTION f_v_fechamento(p_cliente_id integer, p_data

[GENERAL] plpython

2006-10-27 Thread km
Hi all, Can someone hint on resources for using plpython for writing stored procedures ? I have gone thru official docs for 8.1.5 for plpythonu but its not in detail/with examples. When is plpython going to be considered safe ? any targeted version ? regards, KM ---

Re: [GENERAL] plpython error logs

2006-01-31 Thread P. Scott DeVos
Tom Lane wrote: "P. Scott DeVos" <[EMAIL PROTECTED]> writes: When using the Fedora Core 4 rpms for plpython, I find that when an error is raised, the error logger does not report the line number of the python function where the error was raised which makes debugging the functions very difficu

Re: [GENERAL] plpython error logs

2006-01-31 Thread Tom Lane
"P. Scott DeVos" <[EMAIL PROTECTED]> writes: > When using the Fedora Core 4 rpms for plpython, I find that when an > error is raised, the error logger does not report the line number of the > python function where the error was raised which makes debugging the > functions very difficult. > Using t

[GENERAL] plpython error logs

2006-01-31 Thread P. Scott DeVos
Hey all When using the Fedora Core 4 rpms for plpython, I find that when an error is raised, the error logger does not report the line number of the python function where the error was raised which makes debugging the functions very difficult. Using the native Windows installer, the line number

Re: [GENERAL] plpython function with dictionary as function argument?

2005-08-19 Thread Peter Fein
[EMAIL PROTECTED] 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 c

[GENERAL] plpython function with dictionary as function argument?

2005-08-19 Thread gherzig
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

Re: [GENERAL] plpython error since upgrading from 7.x to 8.x

2005-05-25 Thread CSN
Ah, you're right. The function appears to only cause an error on inserts and not updates. Thanks for pointing that out (I'm really green at Python). CSN --- Michael Fuhr <[EMAIL PROTECTED]> wrote: > On Wed, May 25, 2005 at 12:02:22PM -0700, CSN wrote: > > > > It happens when I try to insert ro

Re: [GENERAL] plpython error since upgrading from 7.x to 8.x

2005-05-25 Thread Michael Fuhr
On Wed, May 25, 2005 at 12:02:22PM -0700, CSN wrote: > > It happens when I try to insert rows: > > insert into table1 (col1, col2, col3) values (val1, > val2, val3); > > I have an insert/update trigger on that table, and the > plpythonu function just sends a notification email. > Here's the func

Re: [GENERAL] plpython error since upgrading from 7.x to 8.x

2005-05-25 Thread CSN
It happens when I try to insert rows: insert into table1 (col1, col2, col3) values (val1, val2, val3); I have an insert/update trigger on that table, and the plpythonu function just sends a notification email. Here's the function: if TD["new"]["active"] != TD["old"]["active"]: import

Re: [GENERAL] plpython error since upgrading from 7.x to 8.x

2005-05-25 Thread Michael Fuhr
On Wed, May 25, 2005 at 02:04:22AM -0700, CSN wrote: > > I had a plpythonu function that worked in 7.x but > since upgrading to 8.x it's giving this error: > > ERROR: plpython: function "notify" failed > DETAIL: exceptions.TypeError: unsubscriptable object Could you post a simple, self-containe

[GENERAL] plpython error since upgrading from 7.x to 8.x

2005-05-25 Thread CSN
I had a plpythonu function that worked in 7.x but since upgrading to 8.x it's giving this error: ERROR: plpython: function "notify" failed DETAIL: exceptions.TypeError: unsubscriptable object plpythonu IS installed in the database in which I'm trying to use the function. Any idea what the probl

[GENERAL] plpython multi row return workaround

2005-05-18 Thread Sim Zacks
I've seen other people with this question and today it hit me full force because I need to expand a string and then return all the results. the problem is that string parsing is best done in python, but as far as I could figure out, python only allows 1 result returned. The problem: I have data in

Re: [GENERAL] plpython setof row

2005-05-17 Thread Sim Zacks
As far as I can tell it can't be done. "Mage" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >Hello, > > how can I return setof rows in plpython language? > > I read the manual and couldn't find. > >Mage > > > > ---(end of broadcast)

[GENERAL] plpython setof row

2005-05-11 Thread Mage
Hello, how can I return setof rows in plpython language? I read the manual and couldn't find. Mage ---(end of broadcast)--- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes

Re: [GENERAL] plpython bug

2005-05-05 Thread Mage
Update: it might be not plpython, but similar to the plperl bug I found last time. The script which can produce the bug: create table test (id int, date timestamp); create or replace function trigger_test() returns trigger as $$ plpy.info(TD['new']) return 'MODIFY' $$ language plpytho

[GENERAL] plpython bug

2005-05-04 Thread Mage
Hello! create or replace function trigger_keywords_maintain() returns trigger as $$ return 'MODIFY' $$ language plpythonu; update table set id = id where id = 7 ERROR: invalid input syntax for type timestamp: "2005-05-03 14:07:33,279213" I see that Python's timestamp format is no

Re: [GENERAL] plpython function problem workaround

2005-03-29 Thread Marco Colombo
On Tue, 29 Mar 2005, Marco Colombo wrote: # escapes (expanded by PostgreSQL) q3 = r"select count(f1) from test1 where f1 = 'this is a multi line string\r\nline2\r\nline3\r\n'" curs.execute(q3) ^^ This line (no. 28) is useless (but harmless), please ignore it (just a cut&paste error

Re: [GENERAL] plpython function problem workaround

2005-03-29 Thread Marco Colombo
On Tue, 29 Mar 2005, Sim Zacks wrote: The only ?issue? that I have found with it is similar to an issue I posted about multiline in general, which does not seem to be considered a bug. I've posted similar concerns in the past. The whole point is that there are two possible approaches: 1) treat text

Re: [GENERAL] plpython function problem workaround

2005-03-29 Thread Sim Zacks
The only ?issue? that I have found with it is similar to an issue I posted about multiline in general, which does not seem to be considered a bug. I would say if it is documented that any newlines in a python function, including embedded newlines, are *NIX newlines no matter what operating system t

Re: [GENERAL] plpython function problem workaround

2005-03-27 Thread Michael Fuhr
On Fri, Mar 18, 2005 at 10:12:05PM -0700, Michael Fuhr wrote: > > I just submitted a small patch to convert CRLF => LF, CR => LF. This patch is in 8.0.2beta1, so PL/Python users might want to test it before 8.0.2 is released. See the recent "8.0.2 Beta Available" announcement: http://archives.p

Re: [GENERAL] plpython function problem workaround

2005-03-20 Thread Sim Zacks
Sorry it took me so long to respond. I've been out for a couple days. While certain things may be permissible in a language, I think it is also important to look at the context at which the language is applied and make a determination if it will practically turn up in relevant code. If the answer

Re: [GENERAL] plpython function problem workaround

2005-03-19 Thread Marco Colombo
On Fri, 18 Mar 2005, Tom Lane wrote: Marco Colombo <[EMAIL PROTECTED]> writes: Right now I'm parsing the string first, changing the resulting parse tree adding missing nodes (def, INDENT, DEINDENT) and then compiling it. Hmmm ... is this really going to be simpler or more robust than lexing the str

Re: [GENERAL] plpython function problem workaround

2005-03-18 Thread Michael Fuhr
On Fri, Mar 18, 2005 at 10:33:01AM -0500, Tom Lane wrote: > > I think it would be reasonable to back-patch a small fix to convert CRLF. > The sort of rewrite Marco is considering, I wouldn't back-patch. I just submitted a small patch to convert CRLF => LF, CR => LF. -- Michael Fuhr http://www.f

Re: [GENERAL] plpython function problem workaround

2005-03-18 Thread Tom Lane
Marco Colombo <[EMAIL PROTECTED]> writes: > Right now I'm parsing the string first, changing the resulting > parse tree adding missing nodes (def, INDENT, DEINDENT) and > then compiling it. Hmmm ... is this really going to be simpler or more robust than lexing the string carefully enough to insert

Re: [GENERAL] plpython function problem workaround

2005-03-18 Thread Marco Colombo
On Fri, 18 Mar 2005, Tom Lane wrote: Michael Fuhr <[EMAIL PROTECTED]> writes: On Fri, Mar 18, 2005 at 12:35:07AM -0500, Tom Lane wrote: So that part of it can be solved fairly easily. Should I submit a patch? It should be only a few additional lines in PLy_procedure_munge_source(). Would you app

Re: [GENERAL] plpython function problem workaround

2005-03-18 Thread Tom Lane
Michael Fuhr <[EMAIL PROTECTED]> writes: > On Fri, Mar 18, 2005 at 12:35:07AM -0500, Tom Lane wrote: >> So that part of it can be solved fairly easily. > Should I submit a patch? It should be only a few additional lines > in PLy_procedure_munge_source(). Would you apply it only to HEAD, > or wou

Re: [GENERAL] plpython function problem workaround

2005-03-18 Thread Michael Fuhr
On Fri, Mar 18, 2005 at 11:34:46AM +0100, Marco Colombo wrote: > Just let me suggest not to mimic its behaviour, but to use the > Real Thing if we manage to. That is, directly use the Universal Line > Support code provided by python itself, so that we don't even have > to think about being compati

Re: [GENERAL] plpython function problem workaround

2005-03-18 Thread Marco Colombo
On Thu, 17 Mar 2005, Michael Fuhr wrote: On Thu, Mar 17, 2005 at 09:48:51PM -0500, Tom Lane wrote: Michael Fuhr <[EMAIL PROTECTED]> writes: Line-ending CRs stripped, even inside quotes; mid-line CRs converted to LF. Tests done with Python 2.4 on FreeBSD 4.11-STABLE; I wonder what Python on Windows

Re: [GENERAL] plpython function problem workaround

2005-03-18 Thread Marco Colombo
On Thu, 17 Mar 2005, Tom Lane wrote: Martijn van Oosterhout writes: On Thu, Mar 17, 2005 at 01:03:36PM +0100, Marco Colombo wrote: OMG! It's indenting the funtion body. I think you can't do that w/o being syntax-aware. I'm not familiar with the code, why is it adding a 'def' in front of it at all?

Re: [GENERAL] plpython function problem workaround

2005-03-17 Thread Michael Fuhr
On Fri, Mar 18, 2005 at 12:35:07AM -0500, Tom Lane wrote: > Michael Fuhr <[EMAIL PROTECTED]> writes: > > then concerns about CR conversions potentially messing up a user's > > strings might be unfounded. > > Yeah, it looks like you are right: > > http://cvs.sourceforge.net/viewcvs.py/python/pytho

Re: [GENERAL] plpython function problem workaround

2005-03-17 Thread Tom Lane
Michael Fuhr <[EMAIL PROTECTED]> writes: > Apparently any CR or LF is considered a line > ending in an ordinary Python script, with CR and CRLF normalized > to LF before being passed to the interpreter, so I'm thinking that > a Python programmer wouldn't expect to be able to embed CRs in a > string

Re: [GENERAL] plpython function problem workaround

2005-03-17 Thread Michael Fuhr
On Thu, Mar 17, 2005 at 09:48:51PM -0500, Tom Lane wrote: > Michael Fuhr <[EMAIL PROTECTED]> writes: > > Line-ending CRs stripped, even inside quotes; mid-line CRs converted > > to LF. Tests done with Python 2.4 on FreeBSD 4.11-STABLE; I wonder > > what Python on Windows would do. > > Unfortunate

Re: [GENERAL] plpython function problem workaround

2005-03-17 Thread Tom Lane
Michael Fuhr <[EMAIL PROTECTED]> writes: > Line-ending CRs stripped, even inside quotes; mid-line CRs converted > to LF. Tests done with Python 2.4 on FreeBSD 4.11-STABLE; I wonder > what Python on Windows would do. Unfortunately, I don't think that proves anything, because according to earlier d

Re: [GENERAL] plpython function problem workaround

2005-03-17 Thread Michael Fuhr
On Thu, Mar 17, 2005 at 10:49:24AM -0500, Tom Lane wrote: > Seems like we have to upgrade that thing to have a complete > understanding of Python lexical rules --- at least enough to know where > the line boundaries are. Which is pretty much exactly the same as > knowing which CRs to strip out.

Re: [GENERAL] plpython function problem workaround

2005-03-17 Thread Tom Lane
Martijn van Oosterhout writes: > On Thu, Mar 17, 2005 at 01:03:36PM +0100, Marco Colombo wrote: >> OMG! It's indenting the funtion body. I think you can't do that >> w/o being syntax-aware. I'm not familiar with the code, why is it >> adding a 'def' in front of it at all? I undestand that once you

Re: [GENERAL] plpython function problem workaround

2005-03-17 Thread Martijn van Oosterhout
On Thu, Mar 17, 2005 at 01:03:36PM +0100, Marco Colombo wrote: > OMG! It's indenting the funtion body. I think you can't do that > w/o being syntax-aware. I'm not familiar with the code, why is it > adding a 'def' in front of it at all? I undestand that once you do > it you'll have to shift the cod

Re: [GENERAL] plpython function problem workaround

2005-03-17 Thread Marco Colombo
On Wed, 16 Mar 2005, Michael Fuhr wrote: [I've changed the Subject back to the thread that started this discussion.] On Wed, Mar 16, 2005 at 05:52:02PM +0100, Marco Colombo wrote: I'm against to any on-the-fly conversion, now. I don't like the idea of PostgreSQL accepting input in one form (\r\n) a

Re: [GENERAL] plpython function problem workaround

2005-03-16 Thread Michael Fuhr
[I've changed the Subject back to the thread that started this discussion.] On Wed, Mar 16, 2005 at 05:52:02PM +0100, Marco Colombo wrote: > I'm against to any on-the-fly conversion, now. > I don't like the idea of PostgreSQL accepting input in one form > (\r\n) and providing output in a differe

Re: [GENERAL] plpython function problem workaround

2005-03-16 Thread David
On Tue, Mar 15, 2005 at 03:41:37PM +, Ragnar Hafstað wrote: > On Tue, 2005-03-15 at 07:33 -0600, David wrote: > > > [about the line-termination problem in plpython] > > > I'd like to insert one note here. While I'm not particularly familiar > > with either perl or python, when I encountered

Re: [GENERAL] plpython function problem workaround

2005-03-16 Thread David
On Tue, Mar 15, 2005 at 02:50:06PM -0700, Michael Fuhr wrote: > On Tue, Mar 15, 2005 at 03:41:37PM +, Ragnar Hafstað wrote: > > > actually, perl scripts with \r\n line endings will run just fine in > > unix/linux. > > Indeed, and PL/Perl doesn't care. I just tested several PLs with > Postgre

Re: [GENERAL] plpython function problem workaround

2005-03-15 Thread Michael Fuhr
On Tue, Mar 15, 2005 at 06:03:01PM +0100, Marco Colombo wrote: > On Tue, 15 Mar 2005, Michael Fuhr wrote: > > >I'll postpone commenting on the rest until we find out how the > >example programs run on Windows. If nobody follows up here then > >maybe I'll wander over to comp.lang.python. > > Yeah

  1   2   >