From: | Paul Moore <pf_moore(at)yahoo(dot)co(dot)uk> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: New user: Windows, Postgresql, Python |
Date: | 2005-03-15 22:46:09 |
Message-ID: | uzmx41qa6.fsf@yahoo.co.uk |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
mike(at)fuhr(dot)org (Michael Fuhr) writes:
> We (the thread participants) could use somebody with a Windows
> server to do some testing.
Glad to help... This is with postgresql 8.0.1, Python 2.4.
> Specifically, we're wondering if Python on Windows requires embedded
> Python code to have CRLF (\r\n) as a line ending, or if it requires
> (or at least permits) LF (\n) only. If you're able to help, could
> you could post the results of the following?
>
> CREATE FUNCTION pytest_lf() RETURNS integer AS
> 'x = 1\nreturn x\n'
> LANGUAGE plpythonu;
>
> CREATE FUNCTION pytest_crlf() RETURNS integer AS
> 'x = 1\r\nreturn x\r\n'
> LANGUAGE plpythonu;
>
> SELECT pytest_lf();
> SELECT pytest_crlf();
>
> With PostgreSQL 8.0.1, Python 2.4.1c1, and Solaris 9, I get this:
>
> test=# SELECT pytest_lf();
> pytest_lf
> -----------
> 1
> (1 row)
>
> test=# SELECT pytest_crlf();
> ERROR: plpython: could not compile function "pytest_crlf"
> DETAIL: exceptions.SyntaxError: invalid syntax (line 2)
I get exactly the same results.
> If you have the ability to compile standalone C programs with
> embedded Python, we'd also be interested in seeing what happens if
> you run the programs in the following messages:
>
> http://archives.postgresql.org/pgsql-general/2005-01/msg00876.php
I get:
>test1
What hath
Guido wrought?
> http://archives.postgresql.org/pgsql-general/2005-03/msg00630.php
I get:
>test2
> Initialized.
> Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)]
> running:
print 1
print 2
1
2
> end
> running:
print 1
print 2
File "<string>", line 1
print 1
^
SyntaxError: invalid syntax
> end
> Finalized.
I don't know if this helps? It seems reasonable to me - as far as
Python C code is concerned, code strings should be \n-separated, just
like in Unix. The only place CRLF is applicable is in code read from
files, where the C runtime converts it to \n-delimited before the
Python APIs see it (as far as I understand it, which isn't very
far...)
The long and short of it is that I believe you just use \n to delimit
lines on Windows, just like anywhere else.
Regards,
Paul.
--
SCSI is not magic. There are fundamental technical reasons why it is
necessary to sacrifice a young goat to your SCSI chain now and then.
-- John Woods
From | Date | Subject | |
---|---|---|---|
Next Message | Glenn Sullivan | 2005-03-15 23:14:11 | Installation on XP - Permissions |
Previous Message | Joshua D. Drake | 2005-03-15 22:13:01 | Re: prelimiary performance comparison pgsql vs mysql |