Documentation

The documentation on this page is for the latest release (version 0.1) of csv2sql. You can check which version you have by running:

csv2sql -V

To view the documentation specific to a different version of csv2sql, view the README.md file that comes with your version.

You can also download the last release of csv2sql:

csv2sql [options]

Option Description
-d, --database DATABASE Database to import into. Default is "csv2sql.db"
-e, --encoding INPUT:OUTPUT Input and output encoding. Default is "UTF-8:UTF-8"
-f, --file FILENAME CSV file to import. You can alternately pipe CSV data into standard input
-h, --help Print this help message
-t, --table TABLE Table to import into. Default is the name of the file being imported from or "stdin" if CSV data is from standard input. Periods in the filename are replaced with underscores
-v, --verbose Print verbose output
-V, --version Print version number
  1. Import widgets.csv into the default table (widgets_csv) and database (csv2sql.db):

    csv2sql -f widgets.csv

  2. Import standard input into the "foo" table within the "bar.db" database:

    cat widgets.csv | csv2sql -t foo -d bar.db

  3. Import products.csv and more-products.csv into the "products" table within the default database (csv2sql.db):

    csv2sql -f products.csv -t products

    csv2sql -f more-products.csv -t products

  4. Export data from SQLite sorted by the "ProductName" column to output.csv:

    sqlite3 -header -csv csv2sql.db "SELECT * FROM products ORDER BY ProductName" > output.csv

  1. Verify that you have Ruby 1.9.3 (released October 2011) or later installed:

    ruby --version

    Earlier versions may also work, but are untested.

  2. Verify that you have SQLite 3.6.16 or later installed:

    sqlite3 -version

  3. Verify that you have the sqlite3 Ruby module installed. For example, if you're using RubyGems:

    gem list sqlite3

  4. Download and extract the tarball:

    wget https://github.com/mrideout/csv2sql/archive/v0.1.tar.gz
    tar -xzf v0.1.tar.gz
    cd csv2sql-0.1

  5. Make csv2sql executable:

    chmod 755 csv2sql

  6. Optionally, move **csv2sql** into a directory that's in your PATH. For example:

    sudo mv csv2sql /usr/local/bin/

  1. Fork it.

  2. Create your feature branch:

    git checkout -b my-new-feature

  3. Commit your changes:

    git commit -a -m 'Add some feature'

  4. Push to the branch:

    git push origin my-new-feature

  5. Submit a pull request.

Matt Rideout wrote and released csv2sql in March 2015.

csv2sql is open source software released under the MIT License.