问题
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