csv2sql

Package: WA2L/WinTools 1.2.10
Section: Library Commands (3)
Updated: 07 August 2026
Index Return to Main Contents

 

NAME

csv2sql - convert CSV data to SQL statements

 

SYNOPSIS

WA2LWinTools/lib/[shell/]csv2sql [ -h | -V ]

csv2sql < file.csv

type file.csv | csv2sql

csv2sql [ -t separator ] [ -n tablename ] [ -c columns ] [ output ] < file.csv

type file.csv | csv2sql [ -t separator ] [ -n tablename ] [ -c columns ] [ output ]

---

output    ::= -o ( record | csv | mariadb | mssql | oracle | postgresql | sqlite )

 

AVAILABILITY

WA2L/WinTools

 

DESCRIPTION

The csv2sql command is a filter primarily used to convert CSV data to simple SQL INSERT statements, but it also provides other conversions (RECORD, and CSV).

Furthermore csv2sql removes empty lines and joins prematurely broken CSV lines.

 

OPTIONS

-h
usage message.

-V
print program version.

-t separator
field separator of CSV data.

The default separator is a comma (,).

Whenever the first line in the CSV data is 'sep=C' (example: sep=;) is present that character is used as field separator.

-n tablename
the name of the table to produce the SQL insert statement for.

The default tablename is 'dummy'.

-c columns
case-sensitive comma separated (example: Id,Name,City) list of column names to insert as NULL values into the database; default is to insert an empty string.

-o output_format
format of the data returned by the csv2sql command.

The default output format is mssql.

Supported output_formats are:

csv
CSV, comma (,) separated values file with header row containing the column names.

record
Key : Value record (mostly for verification purposes).

mariadb
SQL statements compatible with the MariaDB/MySQL database to insert the data into the related table.

mssql
SQL statements compatible with the Microsoft™-SQL database to insert the data into the related table.

oracle
SQL statements compatible with the Oracle™ database to insert the data into the related table.

postgresql
SQL statements compatible with the PostgreSQL database to insert the data into the related table.

sqlite
SQL statements compatible with the SQLite database to insert the data into the related table.

file.csv
CSV data provided thru stdin.

 

EXIT STATUS

0
no error.

1
error.

4
usage displayed.

5
version message displayed.

6
command aborted (using Ctrl+C).

 

FILES

-

 

EXAMPLES

-

 

SEE ALSO

wintoolsintro(1), csvgrep(3), csvq(3), csvsort(3), print_list(3), select_columns(3)

 

NOTES

-

 

BUGS

The tested output formats are: record, csv, sqlite and mssql.

The formats mariadb, oracle and postgresql are not tested against a database, it is believed to be correct - however, nothing goes beyond testing, therefore real test results are highly appreciated.

 

AUTHOR

csv2sql was developed by Christian Walther. Send suggestions and bug reports to wa2l@users.sourceforge.net .

 

COPYRIGHT

Copyright © 2026 Christian Walther

This is free software; see https://www.gnu.org/licenses/gpl-2.0.html for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


 

Index

NAME
SYNOPSIS
AVAILABILITY
DESCRIPTION
OPTIONS
EXIT STATUS
FILES
EXAMPLES
SEE ALSO
NOTES
BUGS
AUTHOR
COPYRIGHT

This document was created by man2html, using the manual pages.
Time: 01:17:10 GMT, August 08, 2026