Another option that might work to export any data from any Drupal database table is to use the export capabilities of the Forena module (it comes with quite some community documentation).
About Forena: it is built of the idea of using SQL to get data out of a database (which can be the Drupal database or an external one such as My SQL, Oracle, MS SQL, ...) and use XHTML and CSS to format it into web reports. Visit the Forena HowTos page for some links (near the bottom) to some live demo / showcase links.
Exporting data
Any report can be exported (saved) in various file formats, such as CSV, XLS, PDF, DOC, ... To do so, just add an extention to the report (output) URL that corresponds to the format you want (like .csv
for CSV format). That contains the equivalent of that report (in the requested format). As a sample, consider the sample report located at /reports/sample.states
(in your own site, one of the samples shipped with Forena). Change the URL to /reports/sample.states.csv
(= just add .csv
to it) to get the same report in .csv
format. If you'd add such .csv
to the URL of the Simple Table of States in the demo site, the result is like so ...
Same technique applies for other supported extensions (export formats), such as adding .html
, .xls
(MS Excell), .pdf
or .doc
(MS Word).
By the way, all data blocks are accessible directly via their url also, provided you have permission to access that block. Here are a few samples of that, for the sample report located at /reports/sample.states
:
For short, to answer this specific answer I'd write the various (custom) SQLs I need, format it as reports that fit my needs, and then just save it as a CSV (Or XML? Or JSON?).
Importing data
Using the Forena integration with the Feeds module it is possible to import data blocks.
For a tutorial about the available features check out the video about How to import data and reports based on data as Drupal nodes.
Disclosure: I'm a co-maintainer of the forena module.