CSV to SQL Conversion API

Meet the new enterprise standard for generating SQL statements from CSV files

This tool facilitates the generation of SQL statements from CSV files with ease. Quickly produce CREATE, INSERT, DELETE, UPDATE, MERGE, SELECT, or REPLACE statements

  • 35+ Custom Built in parameters to make conversions easy
  • Generate indexes and primary keys
  • Modify generated SQL by passing "after" keyword phrases
  • Automatic detection of data types and NULL handling
  • Create batch sizes to produce SQL statements in
  • API Design allows you to pass a local file, simple CSV string, or Web URL
  • Extendable to external APIs by passing credentials or OATH
  • Full Documentation and example usage

You must have an API token to call our APIs. You are automatically assigned one upon registering and confirming your email. See our tutorial: Two Methods of API Authentication and Example Use below that demonstrate passing your token to our server. You must substitute your token found in the Account page in place of [YOUR TOKEN]. Also, use your data file name instead of [YOUR FILE], i.e. invoices.csv. All conversion APIs require the infile parameter since it is the data you are converting.
Note that to read from an S3 bucket that requires authorization, you must pass both username and password parameters, and the URL must start with s3://.
There is a 80MB limit on input. You may however zip your input file and use it for infile.

Try it Now

Resulting curl command:

Parameter Value Type Description Example Use
infile


string This is the input file: raw data, or URL. Choose one of the options of "Local File", "URL", or "Data" curl -X POST "https://www.convertcsv.io/api/v1/csv2json/" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string SQL table name curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?tablename=invoice_detail" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string CREATE TABLE {insert text here} ... curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?aftercreate=if+not+exists" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string DROP TABLE {insert text here} ... curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?afterdrop=if+exists" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string INSERT {insert text here} INTO ... Also works with the SQL REPLACEstatement. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?afterinsert=OR+REPLACE" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
integer Group N statements together curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?batch=1000" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
boolean Generate CREATE TABLE command curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?createtable=1" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
boolean Generate DELETE statements curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?delete=1" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string Input file delimiter, default is automatic detection. You usually will not need to use this. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?delimiter=%5E" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
boolean Generate DROP TABLE command - use this with caution. DROP TABLE will be generated before CREATE TABLE. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?droptable=1" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string Name of DUAL table, i.e. dual. Some databases do not require a DUAL table, but others like Oracle do. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?dual=dual" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string File encoding - if not passed, the converter will attempt to determine the encoding by looking at the first few thousand bytes of the file. Typical values are: utf-8, utf-16. You can see a list of all supported types here: https://docs.python.org/3/library/codecs.html curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?encoding=ascii" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
boolean Escape special characters with backslash for SQL strings. Use this mode if generating SQL for MySQL like databases. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?escape=1" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string Exclude these fields in conversion. Use this if you want to convert all fields except these. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?exclude=5" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string Do not output NULL for NULL in these fields. Many CSV files have NULL for NULL fields in a database table. The default is to convert those to NULL in SQL for instance, or null in JSON, however, NULL can be a legitimate value. Use this option to exclude fields from the default conversion. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?exnulls=5" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string Include these fields in conversion. You specify fields by their position, starting at 1. If you wanted the first 5 fields, you can type 1,2,3,4,5 or 1-5. The default is to include all fields. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?fields=1,2,3" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string List of header columns - Use this to override the headers on the CSV file. If the input has no headers (as specified by parameter noheader), then this parameter is a way to specify the headers. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?headover=pk,fullname,amount,comment" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string If you identify a single numeric primary key, use this to add an increment phrase. Use phrases like: IDENTITY or AUTO_INCREMENT, etc. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?increment=IDENTITY" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string Columns to create index on, i.e. 3,4. If generating SQL statements, this will generate a "CREATE INDEX" SQL statement. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?index=3,4" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
boolean Generate INSERT statements curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?insert=1" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string Identify the primary key by column position (starting with 1) curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?key=1" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
integer Limit number of output records to N, i.e. 100. If you have a large output file, use this option to limit your output. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?limit=10" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string Output lower case for these fields curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?lower=6" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
boolean Generate MERGE statements curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?merge=1" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
boolean Input CSV file has no column headings curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?noheader=1" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string Convert 'NULL' to a NULL SQL value or null JSON value. Many popular tools export the string NULL in place of NULL values in tables. By default, the converter will convert ALL NULL values to a NULL SQL value or null JSON value. If you use this option, only the fields specified will be converted. See also exnulls. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?nulls=1,5,6" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
boolean Generate REPLACE SQL statements. Only a few databases support REPLACE, but most support INSERT OR REPLACE. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?replace=1" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string These fields are required, i.e. 5-10. For SQL, this generates a NOT NULL clause in the CREATE TABLE statement. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql/" -F "infile=@[YOUR FILE]" -F "required=1-10" -H "Authorization: Token [YOUR TOKEN]"
integer Sample N record from input file. Default is the whole file. The purpose of sample is to determine the structure and data types of the input file. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?sample=100" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
boolean Generate SELECT SQL statements curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?select=1" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
integer Skip/Ignore N record at top of input file. You may have a CSV file with empty lines or extra verbiage at the top. Use this option to skip those lines. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?skiplines=2" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
boolean TAB is the CSV file delimiter curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?tab=1" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string Trim leading and trailing spaces for these fields. Use column positions to identify the fields. For instance if you always want fields 4 and 5 without leading and trailing spaces, then use this option. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?trim=4,5" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
boolean Unicode Literal support in CSV to SQL. Off by default. Turn on to detect and generate NVARCHAR, NCHAR columns and N prefixed string literals, i.e. N'Welcome' curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?unicode=1" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
boolean Generate UPDATE SQL statements curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?update=1" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
string Output upper case for these fields curl -X POST "https://www.convertcsv.io/api/v1/csv2sql=4,5" -F "infile=@[YOUR FILE]" -F "upper=1-4" -H "Authorization: Token [YOUR TOKEN]"
string Wrap SQL identifier in this character. To wrap in square brackets like SQL Server does, use [ or %5B as a query parameter. The ANSI standard is double quote " and it is used by default. The wrap character is only used when the identifier is not valid without it. You can always wrap identifiers by passing the beginning and ending character. For ANSI: "" (2 double quotes), for SQL Server: [], for MySQL - ``. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?wrap=%5B" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
boolean Input file is an Excel file with either .xlsx or .xls extension. If your column headers do not start on line 1, then use the "skiplines" option to skip to the header or data. curl -X POST "https://www.convertcsv.io/api/v1/csv2sql?xin=1" -F "infile=@[YOUR FILE]" -H "Authorization: Token [YOUR TOKEN]"
<

Pricing

Our Pricing

Free Test Drive

  • Try now and Buy Later - Product plans start at $39/month
  • Test drive ALL our API with no hassle(s)
  • Credit Card is not Required
  • Limited # of Total API calls
Custom

Unique

  • Need something more custom?
  • We can put together custom packages
  • Don't hesitate to contact us
  • We are ready to help!