SQLite: How do I save the result of a query as a CSV file?

后端 未结 6 2052

I\'m new to SQLite. Is there a way I can export the results of a query into a CSV file?

6条回答
  •  被撕碎了的回忆
    2020-11-28 01:28

    To include column names to your csv file you can do the following:

    sqlite> .headers on
    sqlite> .mode csv
    sqlite> .output test.csv
    sqlite> select * from tbl1;
    sqlite> .output stdout
    

    To verify the changes that you have made you can run this command:

    sqlite> .show
    

    Output:

    echo: off   
    explain: off   
    headers: on   
    mode: csv   
    nullvalue: ""  
    output: stdout  
    separator: "|"   
    stats: off   
    width: 22 18 
    

提交回复
热议问题