<div class="gmail_quote">On Thu, Nov 26, 2009 at 2:12 PM, MRAB <span dir="ltr"><<a href="mailto:python@mrabarnett.plus.com">python@mrabarnett.plus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Victor Subervi wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On Thu, Nov 26, 2009 at 1:10 PM, Victor Subervi <<a href="mailto:victorsubervi@gmail.com" target="_blank">victorsubervi@gmail.com</a> <mailto:<a href="mailto:victorsubervi@gmail.com" target="_blank">victorsubervi@gmail.com</a>>> wrote:<br>

<br>
    On Thu, Nov 26, 2009 at 11:52 AM, MRAB <<a href="mailto:python@mrabarnett.plus.com" target="_blank">python@mrabarnett.plus.com</a><br></div><div><div></div><div class="h5">
    <mailto:<a href="mailto:python@mrabarnett.plus.com" target="_blank">python@mrabarnett.plus.com</a>>> wrote:<br>
<br>
        Victor Subervi wrote:<br>
<br>
            On Thu, Nov 26, 2009 at 10:03 AM, Carsten Haese<br>
            <<a href="mailto:carsten.haese@gmail.com" target="_blank">carsten.haese@gmail.com</a> <mailto:<a href="mailto:carsten.haese@gmail.com" target="_blank">carsten.haese@gmail.com</a>><br>
            <mailto:<a href="mailto:carsten.haese@gmail.com" target="_blank">carsten.haese@gmail.com</a><br>
            <mailto:<a href="mailto:carsten.haese@gmail.com" target="_blank">carsten.haese@gmail.com</a>>>> wrote:<br>
<br>
               cursor.execute('update products set pic1=%s where ID=1',<br>
               (MySQLdb.Binary(pic1),))<br>
<br>
               [That comma between the two closing parentheses is not a<br>
            typo. Do not<br>
               leave it out!]<br>
<br>
<br>
            A problem occurred in a Python script. Here is the sequence<br>
            of function calls leading up to the error, in the order they<br>
            occurred.<br>
             /var/www/html/<a href="http://angrynates.com/cart/addEdit.py" target="_blank">angrynates.com/cart/addEdit.py</a><br>
            <<a href="http://angrynates.com/cart/addEdit.py" target="_blank">http://angrynates.com/cart/addEdit.py</a>><br>
            <<a href="http://angrynates.com/cart/addEdit.py" target="_blank">http://angrynates.com/cart/addEdit.py</a>><br>
<br>
              85   print '<body>\n</html>'<br>
              86   db.commit()<br>
              87   cursor.close()<br>
              88<br>
              89 addEdit()<br>
            addEdit = <function addEdit><br>
             /var/www/html/<a href="http://angrynates.com/cart/addEdit.py" target="_blank">angrynates.com/cart/addEdit.py</a><br>
            <<a href="http://angrynates.com/cart/addEdit.py" target="_blank">http://angrynates.com/cart/addEdit.py</a>><br>
            <<a href="http://angrynates.com/cart/addEdit.py" target="_blank">http://angrynates.com/cart/addEdit.py</a>> in addEdit()<br>
<br>
              66       id = 0<br>
              67       cursor.execute(sql)<br>
              68       cursor.execute('update products set pic1=%s where<br>
            ID=1' (MySQLdb.Binary(pics[0]),))<br>
              69       for col in colNamesPics:<br>
            cursor = <MySQLdb.cursors.Cursor object>, cursor.execute =<br>
            <bound method Cursor.execute of <MySQLdb.cursors.Cursor<br>
            object>>, global MySQLdb = <module 'MySQLdb' from<br>
            '/usr/lib64/python2.4/site-packages/MySQLdb/__init__.pyc'>,<br>
            MySQLdb.Binary = <function Binary>, pics =<br>
            ['\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x02\x01\x00H\x00H\x00\x00\xff\xe1\x13\xd5Exif\x00\x00MM\x00*\x00\x00\x00\x08\x00\x07\x01\x12\x00\x03\x00\x00\x00\x01...\xdb\x9f\x94\xa9\xfds\xc9y\xb1W\xda\xd66\x9azS\x84\xd1\x1f\x93\xa9\xfdG\x0fm\xe3\x84\x01\xc5\x94\xfc\x88\xcf\x06f\xc5_\x7fPS6x\x076*\xff\x00\xff\xd9',<br>

            '', '']<br>
<br>
            TypeError: 'str' object is not callable<br>
                 args = ("'str' object is not callable",)<br>
<br>
            Please advise.<br>
<br>
<br>
        On line 68 you have a string literal immediately followed by a<br>
        tuple, so<br>
        it looks like you're trying to call a string, hence the<br>
        exception. Put a<br>
        comma between the string literal and the tuple.<br>
<br>
<br>
Hang on. Not done yet. The line of code I gave you was just a test case. The real ones, and the error they threw, follows:<br>
<br>
A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.<br>
 /var/www/html/<a href="http://angrynates.com/cart/addEdit.py" target="_blank">angrynates.com/cart/addEdit.py</a> <<a href="http://angrynates.com/cart/addEdit.py" target="_blank">http://angrynates.com/cart/addEdit.py</a>><br>
</div></div><div class="im">
   87   print '<body>\n</html>'<br>
   88   db.commit()<br>
   89   cursor.close()<br>
   90<br>
   91 addEdit()<br>
addEdit = <function addEdit><br></div><div class="im">
 /var/www/html/<a href="http://angrynates.com/cart/addEdit.py" target="_blank">angrynates.com/cart/addEdit.py</a> <<a href="http://angrynates.com/cart/addEdit.py" target="_blank">http://angrynates.com/cart/addEdit.py</a>> in addEdit()<br>
</div><div class="im">
   71       for pic in pics:<br>
   72         sql = 'update %s set %s=%s where ID=%s;' % (t, colNamesPics[i], '%s', str(id))<br>
   73         cursor.execute(sql, (MySQLdb.Binary(pics[id]),))<br>
   74         i += 1<br>
   75     elif whatDo == 'insert':<br>
cursor = <MySQLdb.cursors.Cursor object>, cursor.execute = <bound method Cursor.execute of <MySQLdb.cursors.Cursor object>>, sql = 'update products set pic1=%s where ID=1;', global MySQLdb = <module 'MySQLdb' from '/usr/lib64/python2.4/site-packages/MySQLdb/__init__.pyc'>, MySQLdb.Binary = <function Binary>, pics = ['\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x02\x01\x00H\x00H\x00\x00\xff\xe1\x13\xd5Exif\x00\x00MM\x00*\x00\x00\x00\x08\x00\x07\x01\x12\x00\x03\x00\x00\x00\x01...\xdb\x9f\x94\xa9\xfds\xc9y\xb1W\xda\xd66\x9azS\x84\xd1\x1f\x93\xa9\xfdG\x0fm\xe3\x84\x01\xc5\x94\xfc\x88\xcf\x06f\xc5_\x7fPS6x\x076*\xff\x00\xff\xd9'], id = '1'<br>

<br>
TypeError: list indices must be integers<br>
      args = ('list indices must be integers',)<br>
<br>
</div></blockquote>
The traceback explains what the problem is: you're indexing a list, but<br>
the index you're providing isn't an integer.<br>
<br>
Remember that an integer is not a string and a string is not an integer.</blockquote><div><br></div><div>I've been caught on that one more than once. Thanks, that did it :)</div><div>Happy Thanksgiving.</div><div>V</div>
</div>