在MySQL上执行查询时出错

时间:2015-05-11 23:45:31

标签: python mysql file-io load

您好我在执行以下查询时收到以下错误,我正在同时执行两个查询:

CREATE TABLE IF NOT EXISTS Some_Data (Event_index INT, Record_index INT, Device_index SMALLINT, Phone_ID SMALLINT, Transaction_ID SMALLINT, Probe_Seq_Count SMALLINT, Probe_Seq_Result TEXT(100), Duration_Slots INT, Probe_PN SMALLINT, Probe_Sector INT, Probe_Color_Code SMALLINT, Sum_Probe_Count INT) ENGINE = INNODB; 
LOAD DATA LOCAL INFILE '/home/path/data.csv' INTO TABLE Some_Data FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\\n';"
  

错误:查询上传错误:(2014年,“命令不同步;您现在无法运行此命令”)

这是我正在使用的代码,请帮助:

# Connecto to the MySQL server
    self.Connect()

    if(_VERBOSITY):
        print('\tUpload start')

    # Upload the data
    for table in tableDDL:
        try:
            self.cursor.execute(tableDDL[table])
            #self.conn.commit()
            #results = self.cursor.fetchall()
            #print(results)
            break

        except MySQLdb.Error as err:
            print('\tERROR: Query upload Error: %s' % err)
            print('\t%s' % tableDDL[table])
            sys.exit(1)
        except Exception as err:
            print('Error: %s' % err.message)
            sys.exit(1)
        except:
            print('\tERROR: some other error: %s' % (sys.exc_info()[0]))
            sys.exit(1)

用户具有以下权限:

GRANT CREATE, DROP, INSERT, SELECT, UPDATE, DELETE, LOCK TABLES ON access.* TO 'some_user'@'localhost';
GRANT FILE ON *.* TO 'some_user'@'localhost';
FLUSH PRIVILEGES;

谢谢!

0 个答案:

没有答案