Вот код:
# -*- coding: cp866 -*-
f=open(r"C:\\1.txt", "r")
import MySQLdb
con = MySQLdb.connect (host="xxx", user="xxx", passwd="xxx", db="xxx")
cur = con.cursor()
sql="""INSERT INTO `xxx` (`data`) VALUES ('""" + f + """')"""
print sql
try:
cur.execute(sql)
except MySQLdb.DatabaseError, err:
print u"Error ", err
else:
print u"Запрос выполнен"
Traceback (most recent call last):
File "C:\Users\Mictian\Desktop\3.py", line 12, in <module>
sql="""INSERT INTO `xxx` (`data`) VALUES ('"""+f+"""')"""
TypeError: cannot concatenate 'str' and 'file' objects