<div class="gmail_quote">On Sun, Jun 27, 2010 at 3:20 PM,  <span dir="ltr">&lt;<a href="mailto:petkovas@dir.bg">petkovas@dir.bg</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

I have tried the following, too:<br>
<br>
from pg8000 import DBAPI<br>
import os<br>
import os.path<br>
import sys<br>
<br>
# !!! that is test data. It must be changed<br>
conn=DBAPI.connect(host=&quot;localhost&quot;, database=&quot;postgres&quot;, user=&quot;postgres&quot;, password=&quot;test&quot;)<br>
<br>
#conn.cursor will return a cursor oject, you can use this cursor to perform queries<br>
cursor = conn.cursor()<br>
<br>
file = open( &quot;C:\\Blender_Library\\BlenderLib\\objectLib\\Faqns\\Osaka2\\faqns_osaka_2.jpg&quot;, &quot;rb&quot; )<br>
data1 = DBAPI.Binary(file.read())<br>
data2 = &#39;faqns_osaka_2&#39;<br>
        <br>
# execute our Query<br>
cursor.execute(&quot;UPDATE testtable SET jpeg = %s WHERE testtable_n = %s&quot;, data1, data2)<br>
sys.stdout.flush()                                              <br>
<br>
# Save (commit) the changes<br>
conn.commit()<br>
                <br>
# We can also close the cursor if we are done with it<br>
cursor.close()<br>
<br>
The problem this time was:<br>
Traceback &lt;most recent call last&gt;:<br>
   File &quot;insertdb_pg8000.py&quot;, line 19, in &lt;module&gt;<br>
      cursor.execute(&quot;UPDATE testtable SET jpeg = %s WHERE testtable_n = %s&quot;, data1, data2)<br>
   File &quot;build\bdist.win32\egg\pg8000\dbapi.py&quot;, line 243, in _fn<br>
TypeError: execute() takes at most 3 arguments (4 given)<br>
<br></blockquote><div><br>I don&#39;t have any insight into your other piece of code, but here I think you just need another set of parentheses - so that the string interpolation is done first, and the result of it becomes the argument to cursor.execute().  I can&#39;t really test it at the moment, but try changing it to:<br>
cursor.execute( (&quot;UPDATE testtable SET jpeg = %s WHERE testtable_n = %s&quot;, 
data1, data2) )<br><br>Either that, or break it into two lines:<br><br>myQuery = &quot;UPDATE testtable SET jpeg = %s WHERE testtable_n = %s&quot;, 
data1, data2<br>cursor.execute(myQuery)<br><br></div></div>-- <br><a href="http://www.fsrtechnologies.com">www.fsrtechnologies.com</a><br>