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

后端 未结 6 2056

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:35

    Alternatively you can do it in one line (tested in win10)

    sqlite3 -help
    sqlite3 -header -csv db.sqlite 'select * from tbl1;' > test.csv
    

    Bonus: Using powershell with cmdlet and pipe (|).

    get-content query.sql | sqlite3 -header -csv db.sqlite > test.csv
    

    where query.sql is a file containing your SQL query

提交回复
热议问题