SQLizer Logo

Easily convert files into SQL databases

⏎ Back to Help

SQLizer API Reference

Customers with a recurring monthly or annual account for SQLizer get access to our REST API. The following page details the URI endpoints we support and how to use them.

Authentication

All requests made to the API need include a HTTP Authorization header with your API key so we can identify who you are. Your API key can be found on the account page.

The HTTP header should begin with the value "Authorization: Bearer " with your API key following immediately afterwards:

Authorization: Bearer {API-KEY}

POST https://sqlizer.io/api/files/

Sending a POST to this URI will initiate the conversion process. This endpoint accepets the following parameters in the request body. (Using the application/x-www-form-urlencoded content type).

Name Type Required Remarks
FileType String Must be either "csv", "json", "tsv", "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" or "PostgreSQL"
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, tsv, xlsx.

SheetName String

Must be provided for the following FileTypes: xlsx

This value tells SQLizer which sheet on the Excel workbook to load the data from.

CellRange String

Must be provided for the following FileTypes: xlsx

This value tells SQLizer which cells on the specified worksheet to load the data from.

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.

GET https://sqlizer.io/api/files/{ID}/

This endpoint can be used to fetch details about an ongoing file conversion. The ID value in the URI should come from the response to a POST request to /api/files/.

In response to this request, SQLizer will either reply with a HTTP 404 code, or a JSON representation of the file conversion.

The response will contain a single JSON object, with the following properties:

Property Type Remarks
ID String A base64 ID for the current file entity
Filename String The name of the file that was (or is being) uploaded.
FileType String The type of file being converted. This will be either: "csv", "json", "tsv", "xlsx" or "xml".
DatabaseType String The type of SQL syntax being generated. This will be either: "MySQL", "SQLServer" or "PostgreSQL".
TableName String The table name that was requested when the conversion was initiated. SQLizer may alter this value in the final SQL file that is produced. Anything other than alphanumeric characters and underscores will be removed.
Status String Will be one of the following values: "New", "Uploaded", "Analysing", "Processing", "Complete", "Failed", "SubscriptionRequired", "PaymentRequired". See below for details on what each status means.
CheckTableExists Boolean Indicates whether the resulting SQL file will check the table doesn't exist before attempting to create it.
InsertSpacing Integer The number of rows of values to generate per insert statement.
FileHasHeaders Boolean Indicates whether the first row of the input file is being used as the set of column names and excluding from the analysis of what data type each column is.
SheetName String When converting Excel files, this value contains the name of the worksheet that data is being loaded from.
CellRange String When converting Excel files, this value contains the cell range that data is being loaded from. This value will be similar to "A1:GB10000"
PercentComplete Integer During the upload, analysing or processing stages, this value indicates how far through that stage SQLizer believes it is.
ResultUrl String Once the conversion reaches a status of "Complete" this property contains the location of the SQL file that has been produced. The file at that URL can be downloaded without the SQLizer authorisation header.
ResultRows Integer Once the conversion reaches a status of "Complete" this property contains the number of result rows of data SQLizer found in the input file and has added to the resulting SQL file.
Message String If the conversion reaches a status of "Failed" this property contains a description of the problem, if SQLizer is able to determine what the problem was.

Conversion Statuses

Status Description
New The file conversion entity has been created but the data has not been uploaded yet and the conversion process has not begun.
Uploaded The data has been uploaded and the client has updated the file conversion entity to tell SQLizer it can begin analysing, but analysis has not begun yet.
Analysing SQLizer has begun analysing the input file.
Processing SQLizer has completed it's analysis of the input file, and is generated the resulting SQL file.
Complete SQLizer has completed generating the resulting SQL file and the conversion process was successful. The "ResultUrl" property will contain the location of the resulting SQL file.
Failed SQLizer has stopped the conversion process because an error was encountered. The "Message" property might contain more information on why.
SubscriptionRequired The conversion process was initiated without a valid API key, or the user's 24 hour pass has expired, and the input file contains more than 5000 rows of data, which is above our free usage limit. The user should sign up for an account to obtain a valid API key, or purchase a subscription then repeat the conversion attempt.
PaymentRequired The users has a valid account, but a payment has been missed and the input file contains more than 5000 rows of data, which is above our free usage limit. The user should update their payment details on the /account/ page and repeat the conversion attempt.

PUT https://sqlizer.io/api/files/{ID}/

This endpoint can be used to update the properties of a file conversion entity. It accepts the following parameters:

Name Type Required Remarks
Status String The only value ever provided when calling this endpoint should be "Uploaded". This is used to tell SQLizer that the upload process has finished and it can begin analysing the input file.

DELETE https://sqlizer.io/api/files/{ID}/

This endpoint can be used to remove the uploaded file and the generated result file from SQLizer's servers. This endpoint does not accpet any parameters. When this endpoint is called, SQLizer will respond with a status message, such as:

{
    "Status": "Ok"
}

POST https://sqlizer.io/api/files/{ID}/data/

This endpoint is used to upload the input file that SQLizer should convert into SQL. Unlike the other endpoints, the request body should be encoded with the "multipart/form-data" content type. It accepts the following parameters:

Name Type Required Remarks
file application/octet-stream The value of this parameter may contain either the entire contents of the input file. Or a part of the file. If the file is larger than 100Mb, we recommend splitting the file into multiple parts and uploaded them separately and using the PartNumber parameter to identify each part.
PartNumber Integer

Used to tell SQLizer that the "file" parameter only contains a part of the overall input file. Once all parts have been uploaded, each of the parts provided will be combined in their "PartNumber" order before the conversion continues.

Each part with exception of the last part must be at least 5Mb (5,242,880 bytes) but must be no more than 10,000,000 bytes. The final part must be no more than 10,000,000 bytes.

If the upload was successful, SQLizer will respond with a HTTP 200 code and a JSON status message, similar to the following:

{
    "Status": "Ok"
}