我正在使用循环将行添加到SQLite数据库中以进行一些计算。循环必须迭代1000次才能添加我的所有数据。我在不同的迭代中不断出现相同的错误:OperationalError:尝试编写一个只读数据库 SQLite数据库似乎不够快,无法保存输入
conn = sqlite3.connect('BA.db')
c = conn.cursor()
c.execute(('CREATE TABLE IF NOT EXISTS reviews_table(data TEXT, review TEXT, usefulness_rank INTEGER, Satzanzahl_review, Wortanzahl_review, Nr_keywords, positives_Sentiment, negatives_Sentiment)'))
c.execute('INSERT INTO reviews_table(data, review, usefulness_rank, Satzanzahl_review, Wortanzahl_review, Nr_keywords, positives_Sentiment, negatives_Sentiment) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', ((data),(review),(usefulness_rank),(Satzanzahl_review),(Wortanzahl_review),(Nr_keywords),(positives_Sentiment),(negatives_Sentiment)))
c.execute(('CREATE TABLE IF NOT EXISTS summary_project_NLTK(data TEXT, summary_NLTK TEXT, reduction_score_NLTK REAL, Satzanzahl_summary_NLTK INTEGER, Wortanzahl_summary_NLTK INTEGER , Laufzeit_NLTK REAL)'))
c.execute('INSERT INTO summary_project_NLTK (data, summary_NLTK, reduction_score_NLTK, Satzanzahl_summary_NLTK, Wortanzahl_summary_NLTK, Laufzeit_NLTK) VALUES (?, ?, ?, ?, ?, ?)', ((data),(summary_NLTK),(reduction_score_NLTK),(Satzanzahl_summary_NLTK), (Wortanzahl_summary_NLTK),(Laufzeit_NLTK)))
c.execute('UPDATE summary_project_NLTK SET reduction_score_NLTK = null where reduction_score_NLTK = "NULL"')
c.execute(('CREATE TABLE IF NOT EXISTS summary_project_gensim(data TEXT, summary_gensim TEXT, reduction_score_gensim REAL, Satzanzahl_summary_gensim, Wortanzahl_summary_gensim, bleu_score_gensims REAL, Laufzeit_gensim)'))
c.execute('INSERT INTO summary_project_gensim (data, summary_gensim, reduction_score_gensim, Satzanzahl_summary_gensim, Wortanzahl_summary_gensim, Laufzeit_gensim) VALUES (?, ?, ?, ?, ?, ?)', ((data),(summary_gensim),(reduction_score_gensim),(Satzanzahl_summary_gensim),(Wortanzahl_summary_gensim),(Laufzeit_gensim)))
c.execute('UPDATE summary_project_gensim SET reduction_score_gensim = null where reduction_score_gensim = "NULL"')
c.execute(('CREATE TABLE IF NOT EXISTS summary_project_pytextrank(data TEXT, summary_pytextrank TEXT, reduction_score_pytextrank REAL, Satzanzahl_summary_pytextrank INTEGER, Wortanzahl_summary_pytextrank INTEGER, Laufzeit_pytextrank, bleu_score_pytextranks REAL)'))
c.execute('INSERT INTO summary_project_pytextrank (data, summary_pytextrank, reduction_score_pytextrank, Satzanzahl_summary_pytextrank, Wortanzahl_summary_pytextrank, Laufzeit_pytextrank) VALUES (?, ?, ?, ?, ?, ?)', ((data),(summary_pytextrank),(reduction_score_pytextrank),(Satzanzahl_summary_pytextrank), (Wortanzahl_summary_pytextrank), (Laufzeit_pytextrank)))
c.execute('UPDATE summary_project_pytextrank SET reduction_score_pytextrank = null where reduction_score_pytextrank = "NULL"')
conn.commit()
conn.close()