-
Notifications
You must be signed in to change notification settings - Fork 873
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
更新数据报"too many SQL variables"的解决办法 #79
Comments
“too many SQL variables” 错误会在某些sqlite版本出现,这是sqlite 参数长度限制 的设置。 PS:目前mac,linux下暂时没碰到。根本原因是在更新数据时,传入长串的id判断是否重复导致。 |
目前测试win环境下会遇到该问题,主要原因是参数过多超过了SQLite允许的上线(999)。 参见:https://stackoverflow.com/questions/26971050/sqlalchemy-sqlite-too-many-sql-variables |
@scanfyu 可以做个判断,win下df_to_db把sub_size设得足够足够小。。 |
修复 zvtvz#79 在win环境下sqlite一次性插入过多数据报错的问题。
sqlite variables的限制,可以通过命令行来更改:
|
➜ ~ sqlite3 |
将SQLite的版本升级到3.32.0以上即可解决。 windows下: 1、关闭anaconda里的程序; 2、下载sqlite3最新版 https://www.sqlite.org/download.html sqlite-dll-win64-x64-3340100.zip(根据情况,选择相应版本,这里选择64位的) 解压:sqlite3.dll,sqlite3.exe 3、打开:\Anaconda3\Library\bin 替换 sqlite3.dll,sqlite3.exe |
MAC版本信息 sqlite版本 python版本3.7,遇到too many问题,后安装python3.9解决 |
命令后没有修改数据,经过检查 python3.7无法解决,更换sqllite3也不行。windows下预编译版本sqlite variables的限制是无法改变的。 |
安装完以后执行 Stock.record_data()接口,provider指定eastmoney和exchange都报错误
Stock registered recorders:{'joinquant': <class 'zvt.recorders.joinquant.meta.china_stock_meta_recorder.JqChinaStockRecorder'>, 'exchange': <class 'zvt.recorders.exchange.china_stock_list_spider.ExchangeChinaStockListRecorder'>, 'eastmoney': <class 'zvt.recorders.eastmoney.meta.china_stock_meta_recorder.EastmoneyChinaStockListRecorder'>}
Empty DataFrame
Columns: [code, name, list_date]
Index: []
Traceback (most recent call last):
File "D:\Anaconda3\lib\site-packages\sqlalchemy\engine\base.py", line 1193, in _execute_context
context)
File "D:\Anaconda3\lib\site-packages\sqlalchemy\engine\default.py", line 509, in do_execute
cursor.execute(statement, parameters)
sqlite3.OperationalError: too many SQL variables
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "", line 1, in
File "D:\Anaconda3\lib\site-packages\zvt\contract\schema.py", line 152, in record_data
r.run()
File "D:\Anaconda3\lib\site-packages\zvt\recorders\exchange\china_stock_list_spider.py", line 23, in run
self.download_stock_list(response=resp, exchange='sh')
File "D:\Anaconda3\lib\site-packages\zvt\recorders\exchange\china_stock_list_spider.py", line 60, in download_stock_list
df_to_db(df=df, data_schema=self.data_schema, provider=self.provider, force_update=False)
File "D:\Anaconda3\lib\site-packages\zvt\contract\api.py", line 446, in df_to_db
The text was updated successfully, but these errors were encountered: