From: | Jeroen Vermeulen <jtv(at)xs4all(dot)nl> |
---|---|
To: | Whit Armstrong <armstrong(dot)whit(at)gmail(dot)com> |
Cc: | pgsql-interfaces(at)postgresql(dot)org |
Subject: | Re: simple example of copying data from a c/c++ array into postgres |
Date: | 2008-12-11 16:20:55 |
Message-ID: | 49413DE7.8040703@xs4all.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-interfaces |
Whit Armstrong wrote:
> can copy be used to append data to a table?
Yes. The only thing it will not do for you is update existing rows.
> The only reason I'm hesitant to use the copy command is because I
> would have to render every row of my data to a string, and 64bit
> doubles could mean long strings, formating issues, etc.
>
> roughly what I was thinking was (this is pseudocode):
>
> PGtuple myTuple = createTuple();
> myTuple.push_back(toPGDate(myDate));
> myTuple.push_back(toPGDouble(myDouble));
> etc...
>
> PGinsert_tuple(conn, myDestinationTable, myTuple);
>
> are there facilities to do something like that, or am I really reaching here?
In libpqxx I mostly provide self-made text conversions, but you can also
use the standard library to "print" most values into text buffers. Just
be sure to use the C locale where you do this, or you might end up with
strange bugs depending on local notations!
Jeroen
From | Date | Subject | |
---|---|---|---|
Next Message | Whit Armstrong | 2008-12-11 16:37:11 | Re: simple example of copying data from a c/c++ array into postgres |
Previous Message | Whit Armstrong | 2008-12-09 17:36:35 | Re: simple example of copying data from a c/c++ array into postgres |