Skip site navigation (1) Skip section navigation (2)

simple example of copying data from a c/c++ array into postgres

From: "Whit Armstrong" <armstrong(dot)whit(at)gmail(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: simple example of copying data from a c/c++ array into postgres
Date: 2008-12-09 15:08:35
Message-ID: 8ec76080812090708g93000f9l7e7f3e2162587331@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-interfaces
would someone mind showing me an example of making an insert from binary
data to postgres?
I'm currently doing the inserts via a scripting languge, but I would like to
do them directly in c/c++ code.

my data looks like this (date and double):

2008-12-03         2.6585
2008-12-04         2.5513
2008-12-05         2.7037
2008-12-08         2.7378


my script does something like this:

insert into kls_clnt.obs (id, asofdate, datavalue) values
(100, 2008-12-03, 2.6585);

for every row of the data.

Since, I already have this data in a C array, it must be faster to iterate
through the rows of the array and persist the data directly from C to the
database.   Can someone direct me to a simple example of doing this?

Thanks,
Whit

Responses

pgsql-interfaces by date

Next:From: Jeroen VermeulenDate: 2008-12-09 16:53:05
Subject: Re: simple example of copying data from a c/c++ array into postgres
Previous:From: Haszlakiewicz, EricDate: 2008-12-03 21:27:47
Subject: Re: deallocating prepared statements

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group