Re: Insert with a lot of columns - Mailing list psycopg

From Adrian Klaver
Subject Re: Insert with a lot of columns
Date
Msg-id 52C35D33.1030308@gmail.com
Whole thread Raw
In response to Re: Insert with a lot of columns  (David Kerr <dmk@mr-paradox.net>)
List psycopg
On 12/31/2013 03:47 PM, David Kerr wrote:
>
> On Dec 31, 2013, at 1:30 PM, Adrian Klaver <adrian.klaver@gmail.com> wrote:
>
>> On 12/31/2013 10:56 AM, David Kerr wrote:
>>>
>>> On Dec 31, 2013, at 10:50 AM, Adrian Klaver <adrian.klaver@gmail.com> wrote:

>>
>> Another alternative would be to use the psycopg COPY methods:
>>
>> http://initd.org/psycopg/docs/usage.html#copy
>
> Yeah, i’m doing more than just bulk moving data around so the select / insert pattern
> is more appealing despite the lack of performance / simplicity / elegance of it.
>
> Thanks for the help. I got over the hump and got it working with %(name)s for everything.

One way I tackled this was to use cursor.description to get the fields
names and then build the parameter variables on the fly i.e '%(' +
field_name + ')s' and use that to build a string to put into VALUES.

>
>
>


--
Adrian Klaver
adrian.klaver@gmail.com


psycopg by date:

Previous
From: David Kerr
Date:
Subject: Re: Insert with a lot of columns
Next
From: Daniele Varrazzo
Date:
Subject: Psycopg 2.5.2 released