How to change SQLITE_MAX_COLUMN in Python?

早过忘川 提交于 2021-01-29 11:37:40

问题


all:

I'm a Python user,not familiar with SQLite. I try to write a dataframe with 3892 columns into SQLite table using the dataframe.to_sql() method. And Python told me there is an OperationalError:

After google, I found that the Python embedded SQLite has a default Maximum Number Of Columns of 2000 in one table.(Limits In SQLite) The page said:

The default setting for SQLITE_MAX_COLUMN is 2000. You can change it at compile time to values as large as 32767. 

My question is that: my SQLite version is already complied and embedded in Python, how can I change the default setting of max columns of SQLite in Python?

thanks


回答1:


You cannot change this value without recompiling SQLite.

Having a large number of columns is generally bad form in relational database design. Assuming that having that many columns makes sense for your data, you should consider using a different tool than SQLite, as even the documentation you link to mentions that SQLite has numerous algorithms that provide quadratic performance (O(N2) for N columns).



来源:https://stackoverflow.com/questions/60683510/how-to-change-sqlite-max-column-in-python

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!