database - SQLite 错误 : Expression tree is too large (maximum depth 1000)

标签 database sqlite backup restore

我正在尝试对格式错误的 sqlite 文件进行干净的导出-导入。

使用来自 techblog.dorogin.com/sqliteexception-datab... 的信息,这就是我所做的 sqlite3 oldfile:

  1. .mode 插入
  2. .output 临时文件
  3. .dump

然后我创建了一个新的sqlite3 newfile:

  • .read tempfile

错误:

sqlite> .read tempfile
Error: near line 52330: Expression tree is too large (maximum depth 1000)
Error: near line 53097: Expression tree is too large (maximum depth 1000)
Error: near line 53427: Expression tree is too large (maximum depth 1000)
Error: near line 54013: Expression tree is too large (maximum depth 1000)
Error: near line 54014: Expression tree is too large (maximum depth 1000)
Error: near line 54047: Expression tree is too large (maximum depth 1000)
Error: near line 54048: Expression tree is too large (maximum depth 1000)
Error: near line 54227: Expression tree is too large (maximum depth 1000)
Error: near line 54294: Expression tree is too large (maximum depth 1000)
Error: near line 54373: Expression tree is too large (maximum depth 1000)
Error: near line 54374: Expression tree is too large (maximum depth 1000)
Error: near line 56688: Expression tree is too large (maximum depth 1000)
Error: near line 57950: Expression tree is too large (maximum depth 1000)
Error: near line 58015: Expression tree is too large (maximum depth 1000)
Error: near line 58077: Expression tree is too large (maximum depth 1000)
Error: near line 58246: Expression tree is too large (maximum depth 1000)
Error: near line 59795: Expression tree is too large (maximum depth 1000)
Error: near line 60439: Expression tree is too large (maximum depth 1000)
Error: near line 61501: Expression tree is too large (maximum depth 1000)
Error: near line 61523: Expression tree is too large (maximum depth 1000)
Error: near line 61811: Expression tree is too large (maximum depth 1000)
Error: near line 61824: Expression tree is too large (maximum depth 1000)

在输出文件中,我的最大行数是 35737 个字符。

我该如何修复这个错误?

有哪些解决方案可以对格式错误的 sqlite 文件进行干净的导出-导入?

最佳答案

这是由于 change在 3.18.0 版本的 sqlite3 中:

In the output of the ".dump" command in the CLI, quote newline and carriage-return characters using the char() function, so that they do not get eaten by end-of-line processing logic in the OS or in other command-line utilities and/or libraries.

如果单个字符串值中的换行符过多,则生成的 SQL 表达式会变得过于复杂。

这是 fixed在版本 3.19.0 . 如果您仍在使用 3.18.0,则可以通过将文件转换为使用原始换行符来解决此问题:

sed -e "s/'||char(10)||'/\\n/g" < tempfile > tempfile_with_newlines

关于database - SQLite 错误 : Expression tree is too large (maximum depth 1000),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43145117/

相关文章:

python - 如何在程序运行时使用 python 从数据库获取新数据而不刷新我的程序

java - 如何根据保存在数据库android中的日期和时间设置闹钟

linux - rsync 为看似常规的目录打印 "skipping non-regular file"

google-bigquery - bigquery 备份所有 View 定义

java - 如何动态处理java代码中的新表列

php - 无法使用 PHP 打印数据库值

c++ - 传递给函数调用后的空指针 sqlite3 句柄

java - Maven 不包括 sqlite-jdbc

Neo4j 2.1.2 增量备份失败,全量备份成功

mysql - Django 使用外部 mysql DB - 解决问题的最佳方法