Re: libpq (C++) - Insert binary data

From: GOO Creations <goocreations(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: libpq (C++) - Insert binary data
Date: 2010-10-01 06:58:03
Message-ID: 4CA5867B.5030801@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

thanks for this tip, but as far as I understand it libpqtypes is not
part of the original lipq libary .
This will result in the same problem as with the Qt libraries, it will
add another dependecy to my plugin, which is not allowed.

Chris

On 2010/09/30 10:59 PM, Merlin Moncure wrote:
> On Thu, Sep 30, 2010 at 11:42 AM, GOO Creations<goocreations(at)gmail(dot)com> wrote:
>> Yes there is a reason I'm not using Qt's libraries. Qt doesn't come out
>> with PSQL as default driver (meaning you have to manually download the
>> driver for Qt postgres). I'm developing a plugin for an app that restricts
>> Qt, no extra depedncies are allowed. But the app has libpq as dependcy, so
>> I'm able to use that.
> here is my response from the previous time I answered the question.
> There a number of ways to deal with this (my favorite by far is
> libpqtypes, but I'm quite biased!):
>
> On Wed, Jul 21, 2010 at 9:27 AM, Merlin Moncure<mmoncure(at)gmail(dot)com> wrote:
>> On Mon, Jul 19, 2010 at 8:14 PM, vinicius_bra<viniciusams(at)yahoo(dot)com(dot)br> wrote:
>>> Hi All,
>>>
>>> I'm developing a system in C and I have a unsigned char pointer that
>>> represents a struct and I like to store it in a bytea column in postgreSQL.
>>> How can I do it?
>>> Example:
>> you have several options:
>> *) encode the memory for the structure PQescapeStringConn and send to
>> PQexec (my least favorite method)
>> *) set up a call to PQexecParams (more work, but faster and no escaping)
>> *) make a composite type on the server and send your structure in a
>> more classical SQL way
>> *) use libpqtypes (this is the most set up work, but the best in the
>> long run) :-)
>>
>> w/libpqtypes:
>> PGbytea b = {sizeof(s),&s};
>> PGresult *res = PQexecf(conn, "insert into t values (%bytea)", b);
>> PQclear(res);
>>
>> merlin
>>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michele Petrazzo - Unipex 2010-10-01 07:02:03 Re: [9.0] hot standby plus streaming replication
Previous Message Christian Ullrich 2010-10-01 02:21:33 Re: libpq (C++) - Insert binary data