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

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: libpq (C++) - Insert binary data
Дата
Msg-id AANLkTikpUpioMh_+-tXBdGQQCFLKx2G1iNWbHKECVu-_@mail.gmail.com
обсуждение исходный текст
Ответ на Re: libpq (C++) - Insert binary data  (GOO Creations <goocreations@gmail.com>)
Ответы Re: libpq (C++) - Insert binary data  (GOO Creations <goocreations@gmail.com>)
Список pgsql-general
On Thu, Sep 30, 2010 at 11:42 AM, GOO Creations <goocreations@gmail.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@gmail.com> wrote:
> On Mon, Jul 19, 2010 at 8:14 PM, vinicius_bra <viniciusams@yahoo.com.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
>

В списке pgsql-general по дате отправления:

Предыдущее
От: "Dr. Peter Voigt"
Дата:
Сообщение: Re: PostgreSQL 9.0 (x86-64) and Windows 7 (x86-64) - Unable to install
Следующее
От: Dann Corbit
Дата:
Сообщение: Kudos on the 64 bit PostgreSQL for Windows