1

According to the official documentation this is how you can export a table to .csv:

sqlite> .header on
sqlite> .mode csv
sqlite> .once c:/work/dataout.csv
sqlite> SELECT * FROM tab1;
sqlite> .system c:/work/dataout.csv

However, on line 3 of this sequence of commands I get:

Error: unknown command or invalid arguments:  "once". Enter ".help" for help

My path is valid, I have permission to write to that location. My sqlite3 version is

sqlite> .version
SQLite 3.8.2 2013-12-06 14:53:30 27392118af4c38c5203a04b8013e1afdb1cebd0d

running on Ubuntu 14.04

I have googled for this error message, nothing useful on it this far.


FIX:

sqlite> .header on
sqlite> .mode csv
sqlite> .output dataout.csv 
sqlite> SELECT * FROM tab1

should work for the current version. Otherwise update to a newer version.

2 Answers 2

2

The once command was added in SQLite version 3.8.5 based on the changelog so it doesn't exist in your system. If you really need it you might be able to upgrade your version to a newer one.

If you don't want to / can't upgrade you can use the output command and just run one SQL command after it to get the same effect.

Sign up to request clarification or add additional context in comments.

Comments

1

The .once command in the SQLite 3 shell is from version 3.8.5, circa June 2014. Your version is from before this command was introduced, hence the "unknown command" error.

Either find an up-to-date SQLite package, or compile and install SQLite from source.

1 Comment

OK, I have just realised this by checking the rest of the page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.