创建数据库时需要使用commit()吗?我放在哪里?

import sqlite3
import random
import urllib.request, urllib.parse, urllib.error
from bs4 import BeautifulSoup
import ssl
from urllib.request import urlopen
from collections import Counter
import re

conn = sqlite3.connect('EdwardH.sqlite')
cur = conn.cursor()

cur.execute('DROP TABLE IF EXISTS datasources')
cur.execute('DROP TABLE IF EXISTS StopWords')
cur.execute('DROP TABLE IF EXISTS IMDB')
cur.execute('DROP TABLE IF EXISTS NYT')

cur.execute('CREATE TABLE datasources (id INTEGER PRIMARY KEY , 
datasources INTEGER, description INTEGER, sourceurl WEBSITE )')

cur.execute('CREATE TABLE StopWords(id INTEGER, Word INTEGER, Freq INTEGER)')
cur.execute('CREATE TABLE IMDB(id INTEGER, Word INTEGER, Freq INTEGER  )')
cur.execute('CREATE TABLE NYT(id INTEGER, Word INTEGER, Freq INTEGER  )')

a1 = 0
a2 = 0
c1 = 0
count = {}
fhand1 = urllib.request.urlopen('https://raw.githubusercontent.com/nimdvir/teaching/master/stopwords.txt')

对于fhand1中的行:     打印(line.decode()。strip())

for w in fhand1.read().strip().split():
c1 += 1
w = w.lower();
if w in count:
    count[w] += 1
else:
    count[w] = 1
for w, freq in count.items():
    cur.execute('INSERT INTO StopWords (id, Word, Freq ) VALUES(?,?,?)', 
(c1, w,count))


print(c1)

c2 = 0
count = {}
fhand2 = urllib.request.urlopen('https://raw.githubusercontent.com/nimdvir/teaching/master/imdb.txt')
for line in fhand2:
print(line.decode().strip())
for w in fhand2.read().split():
w = w.lower();
if w in count:
    count[w] += 1
else:
    count[w] = 1
for word, freq in count.items():
cur.execute('INSERT INTO IMDB (id,  Word, Freq ) VALUES(?, ?,?)' 
(c2,w,count))


count={}
fhand3 = urllib.request.urlopen('https://raw.githubusercontent.com/nimdvir/teaching/master/nyt.txt')
for line in fhand3:
print(line.decode().strip())
for w in fhand3.read().split():
w = w.lower();
if w in count:
    count[w] += 1
else:
    count[w] = 1
for word, freq in count.items():
cur.execute('INSERT INTO StopWords ( Word, Freq ) VALUES(?,?)',(w,count))

我想通过StopWords,IMDB和NYT运行数据库,但仍然没有结果。我研究了db.commit(),但不确定该放在哪里。 编辑:我添加了完整的代码,以便您可以查看整个内容并可能发现问题。