Robotframework-Database-Library
Robotframework-Database-Library copied to clipboard
Write query result to CSV
I would like to export my SQL Query result into a CSV file, would it be possible to implement such keyword? Or is there any elegant way how to do it? I find it quite hard to format the query result into a csv format.
Thank you very much Cheers, Lucie
It can be easily added, hovewer I wonder about the approach.
We can for example:
- Add parameter to query keyword to save results (ie
Query ${query} output_path=my_file.csv
) - Add new keyword that can save list of dicts results from query:
${results} Query SELECT * FROM users returnAsDict=${True}
Save Results To CSV ${results} my_file.csv
- Don't add it at all since it's not strictly related to "databases" but more to data handling :) (it could be added in some extra, optional module as often useful keyword).
@amochin What do you think?
I think that including this feature in the library would be too much. Increasing the complexity without a real need. With the database library you can already return query results as a dictionary - which can be written in a csv file using the CSV library or a keyword in Python.