Python和MySQL出现问题

| 我正在尝试将大文本文件导入MySQL数据库。 SQL语句如下:
LOAD DATA INFILE \'/tmp/epf/full/album_popularity_per_genre\' 
INTO TABLE album_popularity_per_genre 
CHARACTER SET UTF8 FIELDS TERMINATED BY X\'01\' LINES TERMINATED BY \'\\n\' 
IGNORE 45 LINES (export_date, storefront_id, genre_id, album_id, album_rank)
上面的代码在run1中运行时可以正常工作,但是当我在Python中使用上述SQL语句编写一个简单函数时,出现错误。 这是Python代码,
def test():
    dbConnection = MySQLdb.connect(
    charset=\'utf8\', 
    host=\'localhost\', 
    user=\'root\', 
    passwd=\'root\', 
    db=\'epf\')

    cursor = dbConnection.cursor()

    exStr = \"\"\"LOAD DATA INFILE \'/tmp/epf/full/album_popularity_per_genre\' 
               INTO TABLE album_popularity_per_genre CHARACTER SET UTF8 
               FIELDS TERMINATED BY X\'01\' LINES TERMINATED BY \'\\n\' 
               IGNORE 45 LINES 
               (export_date, storefront_id, genre_id, album_id, album_rank)\"\"\"

    try:
        cursor.execute(exStr)
    except MySQLdb.Warning, e:
        print \"Warning %s\" % (str(e))
    except MySQLdb.IntegrityError, e:     
        print \"Error %d: %s\" % (e.args[0], e.args[1])

    #Clean up
    cursor.close()
    dbConnection.close()
我得到的错误如下,
Warning Data truncated for column \'album_rank\' at row 1
现在我的问题是,为什么原始SQL语句起作用,但是当我尝试运行Python代码时,没有数据导入数据库?     
已邀请:
Python DBAPI是隐式事务的。尝试在执行后加
dbConnection.commit()
。     

要回复问题请先登录注册