我正在尝试对格式错误的 sqlite 文件进行干净的导出-导入。
使用来自 techblog.dorogin.com/sqliteexception-datab... 的信息,这就是我所做的 sqlite3 oldfile
:
.mode 插入
.output 临时文件
.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/