Executing \i of psql command using libpq library

Started by eroblesalmost 15 years ago3 messagesgeneral
Jump to latest
#1erobles
erobles@sensacd.com.mx

Hi!

How can i get the same behavior of psql -c "\\i './a_lot_of_sentences'" bd user, using the libpq library???

i tried Pqexec(pgconn,"\\i './a_lot_of_sentences'") but didn't work. :(

--
SENSA Control Digital.
Ing. Edmundo Robles Lopez.
Analista Programador.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: erobles (#1)
Re: Executing \i of psql command using libpq library

"Edmundo Robles L." <erobles@sensacd.com.mx> writes:

How can i get the same behavior of psql -c "\\i './a_lot_of_sentences'" bd user, using the libpq library???

libpq does not contain any such behavior, so you can't.

regards, tom lane

#3Josh Kupershmidt
schmiddy@gmail.com
In reply to: Tom Lane (#2)
Re: Executing \i of psql command using libpq library

On Tue, Jun 14, 2011 at 11:51 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:

"Edmundo Robles L." <erobles@sensacd.com.mx> writes:

How can i get the same behavior of psql -c "\\i './a_lot_of_sentences'" bd user, using the libpq library???

libpq does not contain any such behavior, so you can't.

You can take a look at process_file() in psql's command.c if you're
interested to see how psql, which itself uses libpq to talk to
Postgres, implements the \i backslash command.

You haven't really explained why just having your application call out
to psql won't work. You could, of course, attempt to duplicate the
functionality of process_file() but frankly I suspect doing so would
result in a poorly implemented subset of psql.

Josh