Pushing data back to database

Data Processing in Shell

Susan Sun

Data Person

csvsql: documentation

csvsql:

  • execute SQL statements directly on a database
  • supports both creating tables and inserting data.

More option arguments:

  • --insert
  • --db
  • --no-inference & --no-constraints
Data Processing in Shell

csvsql: pushing data back to database

Sample syntax:

csvsql --db "sqlite:///SpotifyDatabase.db" \
       --insert Spotify_MusicAttributes.csv

Note:

  1. Line break is used to keep code clean and readable

  2. Use three forward slashes to initiate database name

  3. End with file extension .db for SQLITE database

Data Processing in Shell

csvsql: pushing data back to database

Sample syntax:

csvsql --db "sqlite:///SpotifyDatabase.db" \
       --insert Spotify_MusicAttributes.csv

Documentation:

csvsql -h
--insert  In addition to creating the table, also insert the
          data into the table. Only valid when --db is specified.
Data Processing in Shell

csvsql: pushing data back to database

Sample syntax:

csvsql --no-inference --no-constraints \
       --db "sqlite:///SpotifyDatabase.db" \
       --insert Spotify_MusicAttributes.csv

Documentation:

csvsql -h
--no-inference   Disable type inference when parsing the input.
--no-constraints Generate a schema without length limits or null checks.
Data Processing in Shell

Let's practice!

Data Processing in Shell

Preparing Video For Download...