我想使用python自动填充数据库 我有四列的桌子 身份证名姓氏手机号码 我正在从文本文件输入名称和姓氏。 这是我正在尝试的
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服务器版本相对应的手册以获取正确的语法
答案 0 :(得分:0)
得到答案:)
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()