Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Igor Sosa Mayor
"Charles Clavadetscher" writes: > Are you sure that you really use exactly the same code? The indication > "survice unknown" seems to point to an error in the URL and not to an > authorization problem. Maybe some encoding problem? THnaks for your hints. Yes, exactly the same code. Exactly the s

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Charles Clavadetscher
Hi Weird. According to http://geopy.readthedocs.org/en/latest/#geopy.exc.GeocoderServiceError this is the most generic exception, only used when there is not a more specific one (which include by the way problems caused by connectivity and authorization). The message of the exception is supposed t

Re: [GENERAL] master/master replication with load balancer in front

2015-08-23 Thread Martín Marqués
El 21/08/15 a las 20:45, Florin Andrei escribió: > > The single instance scheme is not very reliable. I need to build a new > DB backend. I'll set up Postgres 9.4. Ideally, I'd like to setup 2 > instances, each instance placed in a different availability zone. > Master/master replication. I'll put

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Adrian Klaver
On 08/23/2015 12:09 AM, Igor Sosa Mayor wrote: "Charles Clavadetscher" writes: Are you sure that you really use exactly the same code? The indication "survice unknown" seems to point to an error in the URL and not to an authorization problem. Maybe some encoding problem? THnaks for your hint

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread s d
It might be a dumb thought, but... Did you run the script from ipython as postgres user? External programs called by triggers run as postgres, and maybe your postgres user doesn't have rights to reach the remote service. Regards, Sandor On 23 August 2015 at 09:09, Igor Sosa Mayor wrote: > "Ch

Re: [GENERAL] 9.5 beta pg_upgrade documentation

2015-08-23 Thread Andy Colson
I think we should add a step 6.5 (before step 7 Stop both servers) with something like: If you are upgrading both a primary and standby, then we need to make sure the standby is caught up. If you are wal shipping then on primary run: select pg_switch_xlog(); shut down primary before you shut do

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Adrian Klaver
On 08/23/2015 12:09 AM, Igor Sosa Mayor wrote: "Charles Clavadetscher" writes: Are you sure that you really use exactly the same code? The indication "survice unknown" seems to point to an error in the URL and not to an authorization problem. Maybe some encoding problem? THnaks for your hint

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Igor Sosa Mayor
"Charles Clavadetscher" writes: >> Yes, exactly the same code. Exactly the same query: two consoles, one with >> postgres, other with ipython. Postgres gives the error; ipython works. > > Somehow I expected that answer. I am not a python expert, but it happens > that different pieces of code at t

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Igor Sosa Mayor
Adrian Klaver writes: > What happens if you run the function below directly in psql and not > through the trigger? exactly the same error. > Do you have both Python 2 and Python 3 on this machine? I have both. > Did you create both the 2u and 3u variants of plpythonu? I tried both... in my

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Igor Sosa Mayor
s d writes: > It might be a dumb thought, but... thanks. There are not dumb thoughts with such problems... > Did you run the script from ipython as postgres user? > External programs called by triggers run as postgres, and maybe your > postgres user doesn't have rights to reach the remote servi

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Igor Sosa Mayor
Adrian Klaver writes: > I tried it here, using your functions, and could not get it to fail: well... i'm happy my function is working... my 1. procedure in PG... Now maybe I'm able to get it working in my laptop... > So it is something to do with the setup on your laptop. yes, or the network I

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Adrian Klaver
On 08/23/2015 09:53 AM, Igor Sosa Mayor wrote: Adrian Klaver writes: What happens if you run the function below directly in psql and not through the trigger? exactly the same error. Do you have both Python 2 and Python 3 on this machine? I have both. Did you create both the 2u and 3u v

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Adrian Klaver
On 08/23/2015 09:53 AM, Igor Sosa Mayor wrote: Adrian Klaver writes: What happens if you run the function below directly in psql and not through the trigger? exactly the same error. Do you have both Python 2 and Python 3 on this machine? I have both. Did you create both the 2u and 3u v

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Adrian Klaver
On 08/23/2015 10:02 AM, Igor Sosa Mayor wrote: Adrian Klaver writes: I tried it here, using your functions, and could not get it to fail: well... i'm happy my function is working... my 1. procedure in PG... Now maybe I'm able to get it working in my laptop... So it is something to do with

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread s d
On 23 August 2015 at 18:59, Igor Sosa Mayor wrote: > s d writes: > > > It might be a dumb thought, but... > > thanks. There are not dumb thoughts with such problems... > > > Did you run the script from ipython as postgres user? > > External programs called by triggers run as postgres, and maybe

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Igor Sosa Mayor
Adrian Klaver writes: >> I tried both... in my system (archlinux) there is plpython2u and >> plpythonu. I think the 2nd one is python3. > > How did they get there? > > Or more to the point how where they built? just installed with postgresql which comes with archlinux. I did not built anything.

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Igor Sosa Mayor
Adrian Klaver writes: > What is the default system Python? python3. But see my other answer. I dont think this is the problem. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Adrian Klaver
On 08/23/2015 10:38 AM, Igor Sosa Mayor wrote: Adrian Klaver writes: I tried both... in my system (archlinux) there is plpython2u and plpythonu. I think the 2nd one is python3. How did they get there? Or more to the point how where they built? just installed with postgresql which comes wi

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Tom Lane
Igor Sosa Mayor writes: > Adrian Klaver writes: >> Or more to the point how where they built? > just installed with postgresql which comes with archlinux. I did not > built anything. But, really: I dont think the problem is plpython2u o 3: > 1. I have in my system both and both have the same lib

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread John R Pierce
On 8/23/2015 10:49 AM, Tom Lane wrote: However, what this smells like to me is a permissions problem. I think you were way too quick to dismiss the idea that SELinux (or something just like it) is restricting outbound internet connections from Postgres. It's standard for SELinux to be configured

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Dave Potts
In cases like this I normally restart the progresql under strace/truss etc and then wade through the output, it will normally tell me which process was invoked. On 23/08/15 18:49, Tom Lane wrote: > Igor Sosa Mayor writes: >> Adrian Klaver writes: >>> Or more to the point how where they built? >>

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Igor Sosa Mayor
Igor Sosa Mayor writes: > My question is therefore: > 1. is there a way to permit the pl/python to connect to the internet all >the time and with a better configuration? > 2. or should I forget the procedure and write a python script outside >the database? I want to update the situation

[GENERAL] fastes way to retrieve segmented without using loop

2015-08-23 Thread Tom Smith
Hello: I have a time series table, using below sql, loop (psque code), I can get one row for each hour for( H=1: H< 9; H++){ select * from table where t >= H and t < H+1 limit 1 } t (time column) is indexed). Is there a better way to use a issue a SINGLE SQL with an array of time st

Re: [GENERAL] fastes way to retrieve segmented without using loop

2015-08-23 Thread Melvin Davidson
Well, I would say the following might work: SELECT * FROM table WHERE t >=1 LIMIT 8; On Sun, Aug 23, 2015 at 5:05 PM, Tom Smith wrote: > Hello: > > I have a time series table, > using below sql, loop (psque code), I can get one row for each hour > > for( H=1: H< 9; H++){ >selec

Re: [GENERAL] fastes way to retrieve segmented without using loop

2015-08-23 Thread Melvin Davidson
Correction: SELECT DISTINCT ON EXTRACT(HOUR FROM you_time_column) * FROM table WHERE t >=1 LIMIT 8; On Sun, Aug 23, 2015 at 5:38 PM, Melvin Davidson wrote: > Well, I would say the following might work: > > SELECT * > FROM table > WHERE t >=1 > LIMIT 8; > > On S

Re: [GENERAL] fastes way to retrieve segmented without using loop

2015-08-23 Thread John McKown
On Sun, Aug 23, 2015 at 4:05 PM, Tom Smith wrote: > Hello: > > I have a time series table, > using below sql, loop (psque code), I can get one row for each hour > ​s/psque/pseudo/g;​ > > for( H=1: H< 9; H++){ >select * from table where t >= H and t < H+1 limit 1 > } > > t (time co

Re: [GENERAL] fastes way to retrieve segmented without using loop

2015-08-23 Thread John McKown
Melvin's use of DISTINCT ON (...) is superior to my use of DISTINCT(...) because it doesn't return the value to your program. I keep forgetting this way. I learned it the other way. Old dog + new trick == problem. On Sun, Aug 23, 2015 at 5:04 PM, John McKown wrote: > On Sun, Aug 23, 2015 at 4:05

Re: [GENERAL] fastes way to retrieve segmented without using loop

2015-08-23 Thread Melvin Davidson
Yes, I agree. I was a bit confused by the term "time" column. Not mention, the O/S and PG version were not given. If column t is truly type time, then only 24 rows can be returned regardless of limit, as in this Universe, there are only 24 hrs in time. However, if t is a timestamp, that is a whole

Re: [GENERAL] Problem with pl/python procedure connecting to the internet

2015-08-23 Thread Adrian Klaver
On 08/23/2015 01:15 PM, Igor Sosa Mayor wrote: Igor Sosa Mayor writes: My question is therefore: 1. is there a way to permit the pl/python to connect to the internet all the time and with a better configuration? 2. or should I forget the procedure and write a python script outside the

Re: [GENERAL] fastes way to retrieve segmented without using loop

2015-08-23 Thread Tom Smith
Sorry for the confusion. I will later find a better way to present the issue. But thanks for everyone's help. On Sun, Aug 23, 2015 at 6:20 PM, Melvin Davidson wrote: > Yes, I agree. I was a bit confused by the term "time" column. Not mention, > the O/S and PG version were not given. > If column

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-23 Thread Thomas Kellerer
Melvin Davidson schrieb am 22.08.2015 um 21:40: > Thank you for pointing out "run with standard_conforming_strings = ON".. > However, that is NOT the problem. > What is occurring is that the developers are sending strings like 'Mr. > M\'vey', > which, if we set standard_conforming_strings = ON, wo

Re: [GENERAL] PostgreSQL Developer Best Practices

2015-08-23 Thread Thomas Kellerer
Melvin Davidson schrieb am 22.08.2015 um 17:15: > I've attached a file with a few starters that although are numbered, > are in no special order. > 2. End ALL queries with a semi-colon (;) >EG: SELECT some_column FROM a_table; > >Although autocommit is on by default, it is always a go