初学 sqlite ( python )
已经成功尝试把一些数据转移到 db 中,这次不知什么原因,执行了却没有任何数据过去。
查了一些文档,一般都是没有 commit 导致的,可是我已经 commit 了,其中 value 我用 print 打印看过,内容都有(10 列,4k 行左右)。用数据库查看器看下来的结果就是只有 table f65,以及一排 column name,没有数据内容。
求教各位,预先谢谢。还不会用 markdown,手工尽可能排版了,各位将就看。
df = pd.DataFrame(pd.read_excel(r'/Users/' + username + r'/Documents/working/addf6-5.xlsx', header=0))
df = df.replace('#NUM!', '')
value = chain(reversed(grouplist2), df.values.tolist())
for x in value:
(4 个空格)x[4] = str(x[4])
(4 个空格)x[7] = str(x[7])
conn = sqlite3.connect('veradb.db')
c = conn.cursor()
c.execute("DROP TABLE IF EXISTS f65")
conn.commit()
c.close()
conn.close()
conn = sqlite3.connect('veradb.db')
c = conn.cursor()
c.execute("CREATE TABLE IF NOT EXISTS f65 ('offer', 'code', 'desc', 'engine', 'cost', 'supplier', 'remark', 'podate', 'empty', 'border')")
c.executemany("INSERT INTO f65 VALUES (?,?,?,?,?,?,?,?,?,?)", value)
conn.commit()
c.close()
conn.close()