我正在编写一个执行以下操作的简单代码:
所以基本上,这只是打开和关闭'temp'表,这是代码:
import os
import sqlite3
dbPath = '......\\DB.db'
conn = sqlite3.connect(dbPath)
cur = conn.cursor()
cur.execute('SELECT * FROM sqlite_master')
tableList = []
for sql_type, sql_name, tbl_name, rootpage, sql in cur.fetchall():
if sql_type == 'table':
tableList.append(sql_name)
print('Tables currently in DB: ' + ', '.join(tableList))
if 'temp' in tableList:
cur.execute('DROP TABLE temp')
conn.commit()
print('temp table deleted')
else:
cur.execute('CREATE TABLE temp AS SELECT * FROM data')
conn.commit()
print('temp table created')
cur.execute('SELECT * FROM sqlite_master')
tableList = []
for sql_type, sql_name, tbl_name, rootpage, sql in cur.fetchall():
if sql_type == 'table':
tableList.append(sql_name)
print('Tables now in DB: ' + ', '.join(tableList))
conn.close()
当我在VS Code中运行它时,它完成了我想要的一切,但通常以以下EOF错误结尾:
Traceback (most recent call last):
File "c:\Users\andwin\.vscode\extensions\ms-python.python-2018.11.0\pythonFiles\experimental\ptvsd\ptvsd\wrapper.py", line 1339, in done
fut.result()
File "c:\Users\andwin\.vscode\extensions\ms-python.python-2018.11.0\pythonFiles\experimental\ptvsd\ptvsd\futures.py", line 40, in result
reraise(self._exc_info)
File "c:\Users\andwin\.vscode\extensions\ms-python.python-2018.11.0\pythonFiles\experimental\ptvsd\ptvsd\reraise3.py", line 8, in reraise
raise exc_info[1].with_traceback(exc_info[2])
File "c:\Users\andwin\.vscode\extensions\ms-python.python-2018.11.0\pythonFiles\experimental\ptvsd\ptvsd\futures.py", line 149, in callback
x = next(it)
File "c:\Users\andwin\.vscode\extensions\ms-python.python-2018.11.0\pythonFiles\experimental\ptvsd\ptvsd\wrapper.py", line 1556, in on_threads
_, _, resp_args = yield self.pydevd_request(cmd, '')
File "c:\Users\andwin\.vscode\extensions\ms-python.python-2018.11.0\pythonFiles\experimental\ptvsd\ptvsd\wrapper.py", line 1364, in pydevd_request
return self._pydevd_request(self.loop, cmd_id, args)
File "c:\Users\andwin\.vscode\extensions\ms-python.python-2018.11.0\pythonFiles\experimental\ptvsd\ptvsd\wrapper.py", line 453, in pydevd_request
raise EOFError
EOFError
当我通常说时,我的意思是大约90%的时间里,这种不一致对我来说很奇怪又很新。它一定意味着什么,对吧?
我已注释掉多行内容,并修改了我能想到的所有内容,以查看它是否消失了。
谢谢!