Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Export csv from mysql by query
mysql -u USER -p -B DB < QUERY.sql | sed 's/"/\\"/g' | sed "s/'/\'/;s/\t/\",\"/g;s/^/\"/;s/$/\"/;s/\"NULL\"/NULL/g;s/\n//g" >RESULT.csv
@mirkoperillo
Copy link
Author

mirkoperillo commented Dec 2, 2020

This script is an improvement of the original found in a stackoverflow answer
here the original source: https://stackoverflow.com/a/5395421/8511674

The original answer is licensed under CC BY-SA 3.0
This improved script is under the same license

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment