Copying a blob from one mysql record to another with a where clause
RAWBOBB at hotmail.com
Mon Jan 5 03:42:23 CET 2004
(I'm a long term newbie :) )
I wanted to copy a blob's contents in mysql in python from one record to another.
I had a heck of a time with it, so I wanted to post it for others.
The where clause was the tricky part for me.
It probably has poor syntax, but it works.
(Obviously) it can be used cross table and across db's.
con0 = MySQLdb.connect(host="localhost",user="",passwd="",db="in")
con1 = MySQLdb.connect(host="localhost",user="", passwd="", db="in")
sourcefield = 'logo'
sourceid = 2514
# A string
s = 2515
selectstring = "select %s from table where id = %s" % (sourcefield, sourceid)
sourceresult = curs0.fetchone()
cursor1 = con1.cursor()
s1 = "update table set "+ sourcefield + " = %s where id = "
s2 = s1 + str(s)
tup = s2
More information about the Python-list