It is possible export sqlite3 table to csv or xls format? I'm using python 2.7 and sqlite3.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
Yes.Read here sqlitebrowser
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.
External programs: see documentation for sqlite3 for details. You can do it from shell/command line.
On the fly: csv module will help you to handle CSV file format correctly