pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
libpq++:  trouble getting "copy table from" to work...
4+ messages / 2 participants
[nested] [flat]

* libpq++:  trouble getting "copy table from" to work...
@ 2002-04-04 06:57  Carlos Moreno <moreno@mochima.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Carlos Moreno @ 2002-04-04 06:57 UTC (permalink / raw)
  To: pgsql-interfaces


Hi,

I'm trying to insert several records into a table in one shot
(from a C++ program, that is).

All my attempts to use "copy from" have failed.  Is it
possible??  I've tried things like:

PgDatabase db(" ..... ");
db.Exec ("copy deleteme from stdin\n1\tName1\n2\tName2");

And similar things  (with a ; after stdin, with a \n. or
\n\\. at the end of the string -- they all fail with an
ErrorMessage() indicating a syntax error in the statement.

I even tried creating a temporary file and then using
copy from 'filename' -- but I get an error message saying
that I need superuser access to be allowed to copy from
and to regular files...

Help?!!  :-(


Thanks,

Carlos
-- 






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: libpq++:  trouble getting "copy table from" to work...
@ 2002-04-04 09:08  jtv <jtv@xs4all.nl>
  parent: Carlos Moreno <moreno@mochima.com>
  0 siblings, 1 reply; 4+ messages in thread

From: jtv @ 2002-04-04 09:08 UTC (permalink / raw)
  To: Carlos Moreno <moreno@mochima.com>; +Cc: pgsql-interfaces

On Thu, Apr 04, 2002 at 01:57:33AM -0500, Carlos Moreno wrote:
> 
> PgDatabase db(" ..... ");
> db.Exec ("copy deleteme from stdin\n1\tName1\n2\tName2");
 
There are separate calls to actually feed the data to the backend through
stdin.  Unfortunately, these calls are in libpq, and libpq++ does not
expose them so you can't access them without going "underneath" and
coding to the C API.

#include <stdplug>

...

May I suggest checking out libpqxx, an alternative to libpq++ that does
expose 'copy from stdin'?  It's at

  http://members.ams.chello.nl/j.vermeulen31/proj-libpqxx.html

The stuff you're looking for is in the TableWriter class.


Jeroen




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: libpq++:  trouble getting "copy table from" to work...
@ 2002-04-04 09:24  Carlos Moreno <moreno@mochima.com>
  parent: jtv <jtv@xs4all.nl>
  0 siblings, 1 reply; 4+ messages in thread

From: Carlos Moreno @ 2002-04-04 09:24 UTC (permalink / raw)
  To: jtv <jtv@xs4all.nl>; pgsql-interfaces


Thanks for your reply, Jeroen,

>May I suggest checking out libpqxx, an alternative to libpq++ that does
>expose 'copy from stdin'?  It's at
>
>  http://members.ams.chello.nl/j.vermeulen31/proj-libpqxx.html
>
>The stuff you're looking for is in the TableWriter class.
>
Hmmm...  I've been *very* tempted to check out this library,
but have been too busy with a project that is already using
libpq++  (not that it is excessively long, but still, changing
everything scares me, mainly because I'm already overflowed
with the tasks that were due yesterday!  :-( )

One always wonders...  Is it more the time that I'm going to
spend learning/understanding this new library and translating
all the code to it?  Or will I end up hating myself and wishing
I had decided to go with this new library when I keep hitting
walls here and there?  (the reluctance to switch is even higher
when you are in the middle of urgent "repairs" to an already
functional system...)

BTW, I didn't find any links to the documentation from the
link you gave me...  I recall you mentioning some docs that
were available.  Could you send me a pointer to it?

Thanks!

Carlos
--






^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: libpq++:  trouble getting "copy table from" to work...
@ 2002-04-04 16:54  jtv <jtv@xs4all.nl>
  parent: Carlos Moreno <moreno@mochima.com>
  0 siblings, 0 replies; 4+ messages in thread

From: jtv @ 2002-04-04 16:54 UTC (permalink / raw)
  To: Carlos Moreno <moreno@mochima.com>; +Cc: pgsql-interfaces

On Thu, Apr 04, 2002 at 04:24:41AM -0500, Carlos Moreno wrote:
>
> Hmmm...  I've been *very* tempted to check out this library,
> but have been too busy with a project that is already using
> libpq++  (not that it is excessively long, but still, changing
> everything scares me, mainly because I'm already overflowed
> with the tasks that were due yesterday!  :-( )
 
One thing I guess it depends on is the C++ "dialect" you're using.  If
you're using C++ as the proverbial "a better C," then libpqxx is not
for you.  But if the existing code deals with and uses exceptions and
such, libpqxx should make your life a lot easier.  No more checking
for errors in return values, no more manual conversion of fields to
integers, no more GetValue().

Perhaps (when I've got time--the weather's too good now!) I should
put together some examples of converting code from libpq++ to libpqxx.


> BTW, I didn't find any links to the documentation from the
> link you gave me...  I recall you mentioning some docs that
> were available.  Could you send me a pointer to it?

They're in the archive.  I'll put them up separately as well.


Jeroen




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2002-04-04 16:54 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-04-04 06:57 libpq++:  trouble getting "copy table from" to work... Carlos Moreno <moreno@mochima.com>
2002-04-04 09:08 ` jtv <jtv@xs4all.nl>
2002-04-04 09:24   ` Carlos Moreno <moreno@mochima.com>
2002-04-04 16:54     ` jtv <jtv@xs4all.nl>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox