pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Whit Armstrong <armstrong.whit@gmail.com>
To: Jeroen Vermeulen <jtv@xs4all.nl>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: simple example of copying data from a c/c++ array into postgres
Date: Thu, 11 Dec 2008 11:37:11 -0500
Message-ID: <8ec76080812110837y44785948gc9f367740c91071d@mail.gmail.com> (raw)
In-Reply-To: <49413DE7.8040703@xs4all.nl>
References: <8ec76080812090708g93000f9l7e7f3e2162587331@mail.gmail.com>
	<493EA271.8010209@xs4all.nl>
	<8ec76080812090936g596abf91jdd8a184c3f56c32@mail.gmail.com>
	<49413DE7.8040703@xs4all.nl>

Thanks, Jeroen.

just want to make sure I understand the convention for libpq and libpqxx.

the convention for getting data into postgres is to convert everything
to strings first?  even if the data is already stored as a 64bit
double in the client app?

-Whit


On Thu, Dec 11, 2008 at 11:20 AM, Jeroen Vermeulen <jtv@xs4all.nl> wrote:
> 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
>



view thread (9+ messages)  latest in thread

Message-ID: <8ec76080812110837y44785948gc9f367740c91071d@mail.gmail.com>
Permalink:  ../8ec76080812110837y44785948gc9f367740c91071d@mail.gmail.com/
Also on:    postgresql.org/message-id/8ec76080812110837y44785948gc9f367740c91071d@mail.gmail.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: armstrong.whit@gmail.com, jtv@xs4all.nl
  Subject: Re: simple example of copying data from a c/c++ array into postgres
  In-Reply-To: <8ec76080812110837y44785948gc9f367740c91071d@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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