如何在 Python 中更改 SQLITE_MAX_COLUMN? [英] How to change SQLITE_MAX_COLUMN in Python?

查看:19
本文介绍了如何在 Python 中更改 SQLITE_MAX_COLUMN?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

全部:

我是 Python 用户,不熟悉 SQLite.我尝试使用 dataframe.to_sql() 方法将一个包含 3892 列的数据框写入 SQLite 表.Python 告诉我有一个 OperationalError:

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:

google 后发现 Python 嵌入式 SQLite 在一张表中有一个默认的最大列数为 2000.(SQLite 中的限制) 页面说:

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. 

我的问题是:我的 SQLite 版本已经编译并嵌入到 Python 中,如何更改 Python 中 SQLite 的最大列数的默认设置?

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?

谢谢

推荐答案

除非重新编译 SQLite,否则您无法更改此值.

You cannot change this value without recompiling SQLite.

在关系数据库设计中,拥有大量列通常是不好的形式.假设有这么多列对您的数据有意义,您应该考虑使用与 SQLite 不同的工具,因为即使您链接到的文档也提到 SQLite 有许多算法可以提供二次性能(O(N2) 用于 N 列).

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).

这篇关于如何在 Python 中更改 SQLITE_MAX_COLUMN?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆