Thank you very much for your answer!
I post the full solution to anyone else maybe need it:
conn = psycopg2.connect("dbname='...' user='...' host='127.0.0.1' password='....'");
print "I am unable to connect to the database"
curs = conn.cursor()
........ code to create image/graph....... #canvas contains graph
canvas.print_figure(data, dpi=150, format="png")
sql = "update table set image=%s;"
On Fri, Dec 18, 2009 at 3:06 AM, Panagiotis Kontaxis <firstname.lastname@example.org> wrote:http://matplotlib.sourceforge.net/api/pyplot_api.html#matplotlib.pyplot.savefig
> I found only the figure.savefig() function that saves figure's image only as
> a filename in the filesystem and not in a local variable.
savefig can take any file-like object, not just a file name.
Check your matplotlib version, and upgrade if you can.