0
c.execute('''CREATE TABLE IF NOT EXISTS Electronic
(elem_no INTEGER PRIMARY KEY, Econf text)''')
lists = []
for i in range(1,5):
filenm = str(i)+".html"
print(filenm)
vals = []
with open(filenm, "r") as elfile:
for line in elfile:
mstr = "]Electron Configuration"
if mstr in line:
vals.insert(len(vals),"Hello")
print(len(vals))
lists.append(vals)
print(lists)
c.executemany("INSERT INTO Electronic VALUES(?)",lists)
conn.commit()
其中每个[1-5]。html的,我有一句台词:现在数据库python3尺寸误差
\grep "Electron Configuration" 1.html
[186]Electron Configuration 1s^1
,问题是,这个确切的设置,我得到错误:
1.html
1
2.html
1
3.html
1
4.html
1
[['Hello'], ['Hello'], ['Hello'], ['Hello']]
Traceback (most recent call last):
File "elem_parse.py", line 134, in <module>
c.executemany("INSERT INTO Electronic VALUES(?)",lists)
sqlite3.OperationalError: table Electronic has 2 columns but 1 values were supplied
正如我从来没有做过数据库之前,所以我试着用:
c.executemany("INSERT INTO Electronic VALUES(?,?)",lists)
即增加无场的价值观,然后给错误:
1.html
1
2.html
1
3.html
1
4.html
1
[['Hello'], ['Hello'], ['Hello'], ['Hello']]
Traceback (most recent call last):
File "elem_parse.py", line 134, in <module>
c.executemany("INSERT INTO Electronic VALUES(?,?)",lists)
sqlite3.ProgrammingError: Incorrect number of bindings supplied. The current statement uses 2, and there are 1 supplied.
因为我从来没有做过数据库befor,我下面Python-sqlite3 - Auto-increment of not null primary key?
,但现在,我失去了和无法弄清楚问题。