SQLizer Logo

Easily convert files into SQL databases

POST /api/files

Sending a POST to this URI will create a file entity on our system and initiate the conversion process.

This endpoint accepts the following parameters in the request body. These should be encoded using either the form URL encoding or as a JSON object. Set the content-type to either application/x-www-form-urlencoded or application/json depending on the encoding used).

Name Type Required Remarks
FileType String Must be either "csv", "json", "xlsx" or "xml"
FileName String The name of the file that will be uploaded. For most file conversions types this is just used for display purposes. For example, the SQLizer "/files/" page shows a list of previously uploaded files. However, for Excel conversions, the extension of the upload file is significant. Files with an ".xls" extension will be treated as legacy Excel 97 - Excel 2003 Binary file format (BIFF8) files.
TableName String The name of the database table to use. SQLizer may alter this value in order to ensure a valid SQL file is produced. Whitespace from either side of the table name will be trimmed, and any non-alphanumeric characters will be converted to underscores.
DatabaseType String Must be either "MySQL", "SQLServer", "PostgreSQL" or "SQLite"
FileHasHeaders Boolean

Tells SQLizer whether to use the first row of the file for the column names, and exclude it from the analysis of what column types to use. Or to include the first row in the outputted data.

Must be provided for the following FileTypes: csv, xlsx.

Delimiter String

If the FileType is csv, tells SQLizer what characters to use to separate column values.

A value of "\t" can be used to signify a tab character, i.e. a string containing a backslash character followed by the letter t, because many platforms/libraries will not encode a raw tab charater into the JSON payload.

If specified, the value must be 1 character long (except when the value is "\t").

Defaults to a comma "," if not specified.

SheetName String

If the FileType is xlsx, tells SQLizer which worksheet to load data from.

Defaults to the currently active worksheet if not specified.

CellRange String

If the FileType is xlsx, tells SQLizer which range of cells to load data from.

Defaults to the whole worksheet if not specified.

CheckTableExists Boolean

Tells SQLizer to generate SQL code to check the table doesn't exist before attempt to create it. Having scripts that can still run even if the table already exists is useful when using our API to regularly import data into a single table.

Defaults to true.

InsertSpacing Integer

The number of lines of data values to concatenate together in a single insert statement.

Defaults to 250.

SQLizer will respond with either a 40x HTTP code and a JSON status message similar to the following:

    "Status": "Error",
    "Message": "Example error message"

Or SQLizer will respond with a 200 HTTP code a JSON respresentation of the newly created file entity:

    "ID": "7EVHQlVpq6YrRGLxNyjJdZ-b7DN3hcKpbqwK215IyPpE8ZeddSK4GVe_q0LNdCZnNCwOi1ewyTSEVMy6rkpi8g==",
    "DatabaseType": "MySQL",
    "Status": "New",
    "FileType": "xlsx",
    "FileName": "file.xlsx",
    "TableName": "table_name",
    "FileHasHeaders": true,
    "SheetName": "Sheet1",
    "CellRange": "A1:F100",
    "CheckTableExists": true,
    "InsertSpacing": 250

The ID property will be generated by SQLizer and should be used as part of the URL when uploading data or retrieving the status of this entity in the future.

The Status property will be generated by SQLizer and will always start with a value of "New". This value will update during the conversion process.