Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id E1F8364FD48 for ; Thu, 11 Dec 2008 12:37:14 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 24619-07 for ; Thu, 11 Dec 2008 12:37:12 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from rn-out-0910.google.com (rn-out-0910.google.com [64.233.170.189]) by mail.postgresql.org (Postfix) with ESMTP id EE72464FC25 for ; Thu, 11 Dec 2008 12:37:11 -0400 (AST) Received: by rn-out-0910.google.com with SMTP id k40so980213rnd.0 for ; Thu, 11 Dec 2008 08:37:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=WoD3uAlcyCdydLkuod2L8ZsEFB895uOrN7A4+CI37ME=; b=vG8+kWKyqm9JXH6wjri8fb78fg63bnXe2rd2nasT2X4BMw1N9XeOCf+lJ+TkH1DYTq U7HbvuVaRDN9OvSYXXWRt9+nnyQq8W7ahO2iyy7tbfgyrmrGTgrS+G/krVr18V6x9J/z 5xFgPhzmIsETskbuvaS1+ZYwEWFwHUDFX5o0M= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=h5jbE0+pP6gxZ1kMBrkAwF860b3VxQtXYYgcshYQxqNSdPfzAp3v3uqW5m6UVV5CR1 U0gNPqJdr5O2MoBk/M3Xxi1PaLiFP578/i/XgiVac99DQAvspXTw+8+TiAiXuRvNUN02 2cGbNqvviUSQgg/gnxbwTZguunwlbaFvyT0nM= Received: by 10.150.11.6 with SMTP id 6mr4568455ybk.61.1229013431237; Thu, 11 Dec 2008 08:37:11 -0800 (PST) Received: by 10.151.136.2 with HTTP; Thu, 11 Dec 2008 08:37:11 -0800 (PST) Message-ID: <8ec76080812110837y44785948gc9f367740c91071d@mail.gmail.com> Date: Thu, 11 Dec 2008 11:37:11 -0500 From: "Whit Armstrong" To: "Jeroen Vermeulen" Subject: Re: simple example of copying data from a c/c++ array into postgres Cc: pgsql-interfaces@postgresql.org In-Reply-To: <49413DE7.8040703@xs4all.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <8ec76080812090708g93000f9l7e7f3e2162587331@mail.gmail.com> <493EA271.8010209@xs4all.nl> <8ec76080812090936g596abf91jdd8a184c3f56c32@mail.gmail.com> <49413DE7.8040703@xs4all.nl> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200812/13 X-Sequence-Number: 6830 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 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 >