Thread: Call a external app on postgreSQL start-up (windows)

Call a external app on postgreSQL start-up (windows)

From
Maurício Cruz
Date:
Hi all,

I need to execute some rotines on windows every time that postgreSQL is 
start at the server machine,
I was thinking to create a PL/PGSQL to call this executable, or 
something like...

Does any one, have done something like this ? or have any idea ?



Thanks everyone!




Re: Call a external app on postgreSQL start-up (windows)

From
Filip Rembiałkowski
Date:
2011/12/27 Maurício Cruz <cruz@sygecom.com.br>:
> Hi all,
>
> I need to execute some rotines on windows every time that postgreSQL is
> start at the server machine,

before it's started or just after it's started?


> I was thinking to create a PL/PGSQL to call this executable, or something
> like...
there are no triggers other than INSERT/UPDATE/DELETE yet.

I would rather go and create external script
- read lastruntime from savefile (simple one line text file will do)
- connect to postgres and fetch SELECT now(), pg_postmaster_start_time();
- if "pg_postmaster_start_time" is newer than statefile timestamp,
save "now" to savefile and run the job.

(I looked at PgAgent but from the docs I see it does not yet have
"once per server startup" logic).


>
> Does any one, have done something like this ? or have any idea ?
>
>
>
> Thanks everyone!
>
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql


Re: Call a external app on postgreSQL start-up (windows)

From
Filip Rembiałkowski
Date:
2011/12/27 Maurício Cruz <cruz@sygecom.com.br>:
>
> I need to execute it after the postgreSQL started service.

OK, so the method I described should be good for you.
The script could be put in Task Scheduler every 15 minutes, or minimal
delay that is acceptable.
It can be written in windos batch language, or Perl, or Python, or whatever...



please CC the list when replying ( use "reply to all" )


lo_import

From
Maurício Cruz
Date:
Hi all,

I'm trying to use lo_import to import a file into my database, if I 
execute from postgres runing in my local machine
it works perfectly, but if I do it in the postgres runing in the server, 
it says "No such file or directory"

I Guess postgres only see file on the machine it is runing and not 
through the network...
I will have to upload the file into the server and then use import  ?   
is there any other way ?

Thanks every one.
Cruz



Re: lo_import

From
Tim Landscheidt
Date:
Maurício Cruz <cruz@sygecom.com.br> wrote:

> I'm trying to use lo_import to import a file into my
> database, if I execute from postgres runing in my local
> machine
> it works perfectly, but if I do it in the postgres runing in
> the server, it says "No such file or directory"

> I Guess postgres only see file on the machine it is runing
> and not through the network...
> I will have to upload the file into the server and then use
> import  ?   is there any other way ?

Create a large object and then write to it?  What driver are
you using?

Tim



Re: lo_import

From
Jasen Betts
Date:
On 2012-01-03, Maurício Cruz <cruz@sygecom.com.br> wrote:
> Hi all,
>
> I'm trying to use lo_import to import a file into my database, if I 
> execute from postgres runing in my local machine
> it works perfectly, but if I do it in the postgres runing in the server, 
> it says "No such file or directory"
>
> I Guess postgres only see file on the machine it is runing and not 
> through the network...

It can only see the files the database server can see.

> I will have to upload the file into the server and then use import  ?   

that would work

> is there any other way ?

the "\lo_import" command in psql, which reads files as the current
user anp pushes them through the database connection.
the best way is probably to add the file import feature to your
appplication.

-- 
⚂⚃ 100% natural