看板 Python 關於我們 聯絡資訊
大家好 我現在用pandas的to_sql把一張張的CSV塞進去一個sqlite3的資料庫 我上網看別人在設定chunksize的時候 都可以設個幾千幾萬的 可是我只設了200就會吐錯誤 設150才能跑 sqlite3.OperationalError: too many SQL variables 我的code如下 import sqlite3 import pandas as pd conn = sqlite3.connect("test_2.db") cur = conn.cursor() create_table="CREATE TABLE IF NOT EXISTS test (x,y,value)" cur.execute(create_table) df2=pd.read_csv("test.csv",index_col=False) df2.to_sql('test',conn,if_exists='append', index=False,method='multi',chunksize=200) 請問是因為sqlite3的chunksize真的只有這麼小 還是我哪邊理解錯誤啊? 謝謝大大 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.134.51.64 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1610528148.A.2EA.html
olycats: 我一般都是設5000 但我是用 MySQL 01/14 15:23
olycats: 不過chunck size 沒有一定 要看資料量/欄位數 01/14 15:24
olycats: 有的資料我可以設到10000都沒問題 01/14 15:25