通过命令行导入csv的sqlite错误 [英] sqlite error importing csv through command line

查看:247
本文介绍了通过命令行导入csv的sqlite错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$ sqlite3 test.sql
SQLite version 3.6.12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table test (id integer, author_id integer, title varchar(128), name text);
sqlite> .separator ";"
sqlite> .import sqlite.csv test
sqlite.csv line 3: expected 4 columns of data but found 1
sqlite> .separator ';'
sqlite> .import sqlite.csv test
sqlite.csv line 3: expected 4 columns of data but found 1
sqlite> 

我正在尝试使用导入csv表.作为sqlite的分隔符,但找不到4列.我从sql导出到csv,并选中了在第一行中放入字段名称".我可以在这里丢失一些东西吗?

I am trying to import the csv table with ; as a seperator to sqlite but it wasn't able to find 4 columns. I export from sql to csv with checked 'Put fields names in the first row'. Could I be missing something here?

csv的前5行

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.  

推荐答案

您不能导入具有主键的表,而必须先将其导入到临时表中.

You can't import into a table with a primary key you have to import into a temp table first.

请参见此问题的答案问题

这篇关于通过命令行导入csv的sqlite错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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