Thread: loading a function from a file

loading a function from a file

From
and
Date:
Hi all,
I would like to know how to load a user defined function from a file
written in pl/pgsql.

I have read it on logging
psql -h host database <  create_some_func.sql
but then i am forced to redo the login.Is there another way to do it?

Re: loading a function from a file

From
Merlin Moncure
Date:
On Mon, Mar 26, 2012 at 4:32 AM, and <andreaesposito77@gmail.com> wrote:
> Hi all,
> I would like to know how to load a user defined function from a file
> written in pl/pgsql.
>
> I have read it on logging
> psql -h host database <  create_some_func.sql
> but then i am forced to redo the login.Is there another way to do it?

what is login.ls?  what exactly about the above is not working for you?

merlin

Re: loading a function from a file

From
Andy Colson
Date:
On 3/26/2012 4:32 AM, and wrote:
> Hi all,
> I would like to know how to load a user defined function from a file
> written in pl/pgsql.
>
> I have read it on logging
> psql -h host database<   create_some_func.sql
> but then i am forced to redo the login.Is there another way to do it?
>

You can put default passwords into a .pgpass file, then psql wont prompt
you for it.

-Andy

Re: loading a function from a file

From
Adrian Klaver
Date:
On 03/26/2012 02:32 AM, and wrote:
> Hi all,
> I would like to know how to load a user defined function from a file
> written in pl/pgsql.
>
> I have read it on logging
> psql -h host database<   create_some_func.sql
> but then i am forced to redo the login.Is there another way to do it?

Not sure what you are trying to achieve? If the file/function is outside
the database and you want it inside, at some point you are going to have
to log into the database to make the transfer. If you are working in the
database using psql you can use the \i command:

test=> \i ~/some_dir/some_func_file.sql

If that is not what you are after, then we will need more detail.

>


--
Adrian Klaver
adrian.klaver@gmail.com

Re: loading a function from a file

From
Alban Hertroys
Date:
On 26 March 2012 11:32, and <andreaesposito77@gmail.com> wrote:
> I have read it on logging
> psql -h host database <  create_some_func.sql
> but then i am forced to redo the login.Is there another way to do it?

If you're working on the database server, then you can skip the "-h
host" bit and use a socket.

That does require that you didn't disallow those in pg_hba and that
the OS supports socket files (Windows doesn't, for example).

--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.

Re: loading a function from a file

From
Jasen Betts
Date:
On 2012-03-26, and <andreaesposito77@gmail.com> wrote:
> Hi all,
> I would like to know how to load a user defined function from a file
> written in pl/pgsql.
>
> I have read it on logging
> psql -h host database <  create_some_func.sql
> but then i am forced to redo the login.  Is there another way to do it?

another way use a connection string:
psql "host=name dbname=database password=SECRET" < create_some_func.sql

another is log into psql and issue the \i psql command to read the file

  \i create_some_func.sql

--
⚂⚃ 100% natural