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 sent to the cursor. However, when I attempt to
manual construct the sql insert statment above I get an error:

>>> print "INSERT INTO table (%s) VALUES (%%s);" % (",".join(fields),
*values)
  File "<stdin>", line 1
    print "INSERT INTO table (%s) VALUES (%%s);" % (",".join(fields),
*values)
                                                                      ^
SyntaxError: invalid syntax


-- 
David Bear
-- let me buy your intellectual property, I want to own your thoughts --
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to