[問題] pandas.to_sql chunksize大小

看板Python作者 (逢甲阿法)時間4年前 (2021/01/13 16:55), 編輯推噓0(003)
留言3則, 1人參與, 4年前最新討論串1/1
大家好 我現在用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

01/14 15:23, 4年前 , 1F
我一般都是設5000 但我是用 MySQL
01/14 15:23, 1F

01/14 15:24, 4年前 , 2F
不過chunck size 沒有一定 要看資料量/欄位數
01/14 15:24, 2F

01/14 15:25, 4年前 , 3F
有的資料我可以設到10000都沒問題
01/14 15:25, 3F
文章代碼(AID): #1V_hMKBg (Python)
文章代碼(AID): #1V_hMKBg (Python)