It is possible export sqlite3 table to csv or xls format? I’m using python 2.7 and sqlite3.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I knocked this very basic script together using a slightly modified example class from the docs; it simply exports an entire table to a CSV file:
Hope this helps!
Edit: If you want headers in the CSV, the quick way is to manually add another row before you write the data from the database, e.g:
Edit 2: To output pipe-separated columns, register a custom CSV dialect and pass that into the writer, like so:
Here’s a list of the various formatting parameters you can use with a custom dialect.