回答

收藏

通过命令导入csv的sqlite错误

技术问答 技术问答 279 人阅读 | 0 人回复 | 2023-09-14

$ sqlite3 test.sql
7 t# p1 _" ~; L/ ^                SQLite version 3.6.12, A8 z4 |5 ^$ ~# l
                Enter “.help” for instructions
) k2 y* A& _0 |9 z& q' p                Enter SQL statements terminated with a “;”/ s' T8 o) u# [( a
                sqlite> create table test (id integer,author_id integer,title varchar(128),name text);
. `; Y: c. ^" y, Y: M                sqlite> .separator “;”8 T, e) U$ F8 n0 ?+ q
                sqlite> .import sqlite.csv test
1 e9 t8 P: I; h3 E6 S4 \4 v2 z* L                sqlite.csv line 3: expected 4 columns of data but found 1
  V1 J- l" L2 q3 j                sqlite> .separator ‘;’
7 V7 c7 i, F7 y1 F                sqlite> .import sqlite.csv test
' n$ z$ B! ]. y/ M                sqlite.csv line 3: expected 4 columns of data but found 19 b: }# ~) {& V2 ~: M% b8 J, b9 Z
                sqlite>
6 B! P! W# D# C5 U9 A/ [% F2 c% g我试着使用导入csv表;作为sqlite但是找不到四列分隔符。sql导出到csv,并选择了在第一行放入第一行。我能在这里丢失一些东西吗?& n9 U% N8 B6 G" G3 e9 J- A
CSV的前5行0 O1 d- T! _  q1 J- E8 o
id;"author_id";"title";"poem"       1;"92";"A Letter From Italy";"Salve magna parens frugum Saturnia tellus     Magna virm! tibi res antiqu laudis et artis     Aggredior    sanctos ausus recludere fontes.    Virg. Geor. 2.                2 a" d6 t3 N, [1 f( U
    解决方案:                                                                9 @/ f/ |& V  _  X* u7 t
                                                                不能使用主键导入表,必须先导入临时表。4 U6 w& @2 {# }4 w8 Z
看看这个问题的答案
分享到:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则