我已经在mysql中创建了一个表
create table authorization(
email varchar(50),
orgID int(10),
candidateID varchar(255)
);
我试图在使用uuid v4的表中为candidateID生成uuid。我正试图通过python代码将信息上传到数据库中
file = 'mycsvfile.csv'
data = [row for row in csv.reader(open(file,'r'))]
...
db_data = []
for row in data:
id = uuid.uuid4()
temp = {}
temp['email'] = row[13]
temp['orgID'] = row[1]
temp['candidateID'] = id
db_data.append(temp)
cols = ['email', 'orgid', 'candidateid']
try:
Mysqlfunction.bulk_insert(table, cols, db_data, **CONFIG['database']['test'])
except Exception as error:
print(error)
我犯了一个错误
mysql.connector.errors.InterfaceError: Failed executing the operation; Python type UUID cannot be converted
通过检查一些links,我能够使用uuid4()执行查询,没有任何问题
insert into authorization(email, orgID, candidateID) values("maria@email.com", 1, (select uuid()));
有没有办法直接在变量中使用uuid,这样我就不必每次都运行mysql来生成uuid
目前没有回答
相关问题 更多 >
编程相关推荐