SQLite3 Import Command Not Working

I have been trying to import a CSV file into an SQLite database using Terminal. I have done the following (abbreviated):

-------------

Last login: Sun Mar 15 20:51:38 on ttys000
Macintosh-2:~ Me$ sqlite3
SQLite version 3.4.0
Enter ".help" for instructions

sqlite> create table x1 (...
sqlite> .separator "\t"
sqlite> .import /path/directory/folder/page_topic page_topic

----------------

The import command works, however, it only imports the first row of the CSV file. I created the file using Xcel. Is there some sort of line terminator that I am no accounting for? Is there another part of the command that I should be using? I looked through other forum entries concerning the import command and no one else has experienced this issue.

iMac, Mac OS X (10.5.6)

Posted on Mar 15, 2009 7:35 PM

Reply
5 replies

Jun 10, 2009 7:29 PM in response to DraionMac

I also had this problem, and went with the FireFox add-on as my solution. However, it should be noted that it seems the sqlite we have is a version that doesn't include the import command. When I enter .help, the .import command is not listed, as it is in other .help listings I've seen on the web. I guess the true solution to the problem is to recompile sqlite from source, there being no package I've seen for pre-Leopard, pre-Intel.

Jun 10, 2009 7:34 PM in response to Shawn Reeves1

Oh great, right after my last post I realized the solution to the issue: type sqlite3, not just sqlite at the command prompt. Many of us have an older version (2.8.17 for me in my Tiger installation) in our command path. sqlite3 has the import command, version 2 does not.
Here is the output of .help from sqlite, and below the output from sqlite3:
QuadG5:~ shawn$ sqlite
SQLite version 2.8.17
Enter ".help" for instructions
sqlite> .help
.databases List names and files of attached databases
.dump ?TABLE? ... Dump the database in a text format
.echo ON|OFF Turn command echo on or off
.exit Exit this program
.explain ON|OFF Turn output mode suitable for EXPLAIN on or off.
.header(s) ON|OFF Turn display of headers on or off
.help Show this message
.indices TABLE Show names of all indices on TABLE
.mode MODE Set mode to one of "line(s)", "column(s)",
"insert", "list", or "html"
.mode insert TABLE Generate SQL insert statements for TABLE
.nullvalue STRING Print STRING instead of nothing for NULL data
.output FILENAME Send output to FILENAME
.output stdout Send output to the screen
.prompt MAIN CONTINUE Replace the standard prompts
.quit Exit this program
.read FILENAME Execute SQL in FILENAME
.schema ?TABLE? Show the CREATE statements
.separator STRING Change separator string for "list" mode
.show Show the current values for various settings
.tables ?PATTERN? List names of tables matching a pattern
.timeout MS Try opening locked tables for MS milliseconds
.width NUM NUM ... Set column widths for "column" mode


QuadG5:~ shawn$ sqlite3
SQLite version 3.4.2
Enter ".help" for instructions
sqlite> .help
.bail ON|OFF Stop after hitting an error. Default OFF
.databases List names and files of attached databases
.dump ?TABLE? ... Dump the database in an SQL text format
.echo ON|OFF Turn command echo on or off
.exit Exit this program
.explain ON|OFF Turn output mode suitable for EXPLAIN on or off.
.header(s) ON|OFF Turn display of headers on or off
.help Show this message
.import FILE TABLE Import data from FILE into TABLE
.indices TABLE Show names of all indices on TABLE
.mode MODE ?TABLE? Set output mode where MODE is one of:
csv Comma-separated values
column Left-aligned columns. (See .width)
html HTML <table> code
insert SQL insert statements for TABLE
line One value per line
list Values delimited by .separator string
tabs Tab-separated values
tcl TCL list elements
.nullvalue STRING Print STRING in place of NULL values
.output FILENAME Send output to FILENAME
.output stdout Send output to the screen
.prompt MAIN CONTINUE Replace the standard prompts
.quit Exit this program
.read FILENAME Execute SQL in FILENAME
.schema ?TABLE? Show the CREATE statements
.separator STRING Change separator used by output mode and .import
.show Show the current values for various settings
.tables ?PATTERN? List names of tables matching a LIKE pattern
.timeout MS Try opening locked tables for MS milliseconds
.width NUM NUM ... Set column widths for "column" mode

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

SQLite3 Import Command Not Working

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.