我想自动填充数据库使用python我有4列ID名称姓手机号码,我正在从文本文件名和姓的输入表。这里是单读音尝试
with open("names.txt") as f:
word=f.read()
word=word.split()
with open ("last name.txt") as l:
wordx=l.read().split()
print(wordx)
for (i,j,k) in zip(range(3,12),word,wordx):
insertdata="insert into person(id,firstname,lastname,mobileno) values ('%d','%r','%r','%d')"%(i,tuple(word),tuple(wordx),randint(0000000000, 9999999999))
cursor.execute(insertdata)
connectionvar.commit()
即时得到这个错误pymysql.err.ProgrammingError:(1064,“您的SQL语法错误;检查对应于您的MariaDB的服务器版本正确的语法手册
得到的答案:)
with open("names.txt") as f:
word=f.read()
word=word.split()
with open ("last name.txt") as l:
wordx=l.read().split()
print(wordx)
for (j,k) in zip(word,wordx):
insertdata="insert into person(firstname,lastname,mobileno) values ('%s','%s','%d')"%(j,k,randint(0000000000, 999999999))
cursor.execute(insertdata)
connectionvar.commit()