Carsten Haese wrote:
> The
> example he gave you constructs an insert query with only one parameter
> placeholder. You'll need as many placeholders as the number of values that
> are inserted.
>
> The following example should work better:
>
> def insertDict(curs, tablename, data):
> fields = d
On Mon, 05 Dec 2005 18:00:21 -0700, David Bear wrote
> Fredrik Lundh wrote:
> > DON'T MANUALLY CONSTRUCT THE SQL INSERT STATEMENT. Use string
> > formatting to insert the field names, but let the database layer deal with
> > the values.
> >
> > If you want to do things in two steps, do the fields
Fredrik Lundh wrote:
> David Bear wrote
>
>> Fredrik Lundh wrote:
>>
>> > cursor.execute(
>> > "INSERT INTO table (%s) VALUES (%%s);" % (",".join(fields)),
>> > *values
>> > )
>>
>> Thanks for the hint. However, I don't understand the syntax.
>>
>> I will be inserting in to postgresql
Fredrik Lundh wrote:
> David Bear wrote
>
>> Fredrik Lundh wrote:
>>
>> > cursor.execute(
>> > "INSERT INTO table (%s) VALUES (%%s);" % (",".join(fields)),
>> > *values
>> > )
>>
>> Thanks for the hint. However, I don't understand the syntax.
>>
>> I will be inserting in to postgresql
David Bear wrote
> Fredrik Lundh wrote:
>
> > cursor.execute(
> > "INSERT INTO table (%s) VALUES (%%s);" % (",".join(fields)),
> > *values
> > )
>
> Thanks for the hint. However, I don't understand the syntax.
>
> I will be inserting in to postgresql 8.x. I assumed the entire string wo
Fredrik Lundh wrote:
> cursor.execute(
> "INSERT INTO table (%s) VALUES (%%s);" % (",".join(fields)),
> *values
> )
Thanks for the hint. However, I don't understand the syntax.
I will be inserting in to postgresql 8.x. I assumed the entire string would
be evaluated prior to being sen
David Bear wrote:
> The dictionary keys are the field names. The values are the values to be
> inserted.
>
> I am looking for a good pythonic way of expressing this, but I have a
> problem with the way lists are represented when converted to strings.
>
> Lets say my dictionary is
>
> data = {"fnam