Data Processing in Shell
Susan Sun
Data Person
sql2csv
:
Documentation:
sql2csv -h
usage: sql2csv [-h] [-v] [-l] [-V] [--db CONNECTION_STRING] [--query QUERY]
[-e ENCODING] [-H]
[FILE]
Sample syntax:
sql2csv --db "sqlite:///SpotifyDatabase.db" \
--query "SELECT * FROM Spotify_Popularity" \
> Spotify_Popularity.csv
1. Establishing database connection:
--db
is followed by the database connection stringsqlite:///
and ends with .db
postgres:///
or mysql:///
and with no .db
Sample syntax:
sql2csv --db "sqlite:///SpotifyDatabase.db" \
--query "SELECT * FROM Spotify_Popularity" \
> Spotify_Popularity.csv
2. Querying against the database:
--query
is followed by the SQL query stringSample syntax:
sql2csv --db "sqlite:///SpotifyDatabase.db" \
--query "SELECT * FROM Spotify_Popularity" \
> Spotify_Popularity.csv
3. Saving the output:
>
: re-directs output to new local CSV fileData Processing in Shell