execute_values

2019-07-09 Thread Weatherby,Gerard
?Can I use pyscopy2.extras.execute_values with a prepared statement?


--
Gerard Weatherby| Application Architect
NMRbox | Department of Molecular Biology and Biophysics | UConn Health
263 Farmington Avenue, Farmington, CT 06030-6406
Phone: 860 679 8484
uchc.edu


Re: execute_values

2019-07-10 Thread Weatherby,Gerard
My insert has a "returning clause," I don't think execute batch supports that.

--
Gerard Weatherby| Application Architect
NMRbox | Department of Molecular Biology and Biophysics | UConn Health
263 Farmington Avenue, Farmington, CT 06030-6406
Phone: 860 679 8484
uchc.edu


From: Adrian Klaver 
Sent: Tuesday, July 9, 2019 4:25 PM
To: Weatherby,Gerard; pgsql-general@lists.postgresql.org
Subject: Re: execute_values

On 7/9/19 11:04 AM, Weatherby,Gerard wrote:
> ​Can I use pyscopy2.extras.execute_values with a prepared statement?

I don't think so as you cannot pass in VALUES():

cur.execute('prepare pt(integer, varchar, boolean) AS INSERT INTO
prepare_test values ($1, $2, $3)')

execute_values(cur, 'EXECUTE pt(%s)', [(2, 'test', 'f'),])

SyntaxError: wrong number of parameters for prepared statement "pt"
DETAIL:  Expected 3 parameters but got 1.


execute_batch works though:

execute_batch(cur, 'EXECUTE pt(%s, %s, %s)', [(2, 'test', 'f'), (3,
'dog', 't')])


>
>
> --
> *Gerard Weatherby*| Application Architect
> NMRbox | Department of Molecular Biology and Biophysics | UConn Health
> 263 Farmington Avenue, Farmington, CT 06030-6406
> Phone: 860 679 8484
> uchc.edu


--
Adrian Klaver
adrian.kla...@aklaver.com


Re: How to run a task continuously in the background

2019-07-17 Thread Weatherby,Gerard
We used a python process running continually on a linux client for the LISTEN 
piece.

Reading the documentation, it seems that a background worker ( 
https://www.postgresql.org/docs/11/bgworker.html) might be a solution to your 
requirements. I don’t have personal experience with them.
--
Gerard Weatherby | Application Architect
NMRbox | Department of Molecular Biology and Biophysics | UConn Health
263 Farmington Avenue, Farmington, CT 06030-6406
Phone: 860 679 8484
uchc.edu

On Jul 17, 2019, at 5:57 AM, Dirk Mika 
mailto:dirk.m...@mikatiming.de>> wrote:

You will have a trigger that, once new tuples are created (or older
update and so on) issues a NOTIFY.
Somewhere (within PostgreSQL or outside it) there will be a process
that issued a LISTEN and is locked until a notify comes in. Then it
does process whatever you need to do.
As an example your trigger function will be something like
>
and your listening process will be something like
>.

Thanks for the examples. I’ll look into them.

This makes your processing fully asynchronous, and with some tune
allows you to decide the start/stop/resume policy as you need/wish.

Besides, it is quite hard for me to get to the point where you need to
check for new data every second, and therefore why you are not
satisfied with pg_cron or stuff like that.

pg_cron doesn’t start the task instantly and queues subsequent runs, if the 
task is still running. I just need to start the task once and it should keep 
running until stopped / killed.

Maybe I'll have to rephrase it.
Suppose I have a procedure and want to start it without the client where I 
start the procedure waiting for it to finish. And I want the procedure to 
continue even if the client that started it quits.
And I want to be able to check if the procedure is still running.

Dirk

--
Dirk Mika
Software Developer





mika:timing GmbH
Strundepark - Kürtener Str. 11b
51465 Bergisch Gladbach
Germany



fon +49 2202 2401-1197
dirk.m...@mikatiming.de
www.mikatiming.de



AG Köln HRB 47509 * WEEE-Reg.-Nr. DE 90029884
Geschäftsführer: Harald Mika, Jörg Mika








NFS version for replication

2020-05-17 Thread Weatherby,Gerard
When setting up an NFS mount for archive WAL logs as described in 
https://www.postgresql.org/docs/12/continuous-archiving.html, is NFS v3 or NFS 
v4 preferred?
--
Gerard Weatherby | Application Architect
NMRbox | Department of Molecular Biology and Biophysics | UConn Health
263 Farmington Avenue, Farmington, CT 06030-6406
Phone: 860 679 8484
uchc.edu