db.sqlite), encoded as base64URL string, as part of your request.
This guide will walk you through everything: from preparing your .sqlite file to encoding and sending it through the API.
What is SQLite
SQLite is a lightweight, self-contained, and serverless relational database engine.Unlike traditional database management systems, it does not require a separate server process, making it ideal for applications that need an embedded database with minimal setup. SQLite stores the entire database, including tables, indexes, and data, in a single.sqlite file, which makes it highly portable and easy to distribute.
It supports standard SQL syntax, transactions, and most common database features, allowing you to run queries,
insert data, and perform updates directly within the database file.
Its simplicity and reliability have made SQLite widely used in desktop applications, mobile apps, and embedded systems.
Head over to SQLite org to learn more about SQLite
How to execute SQL over Fermion API
Fermion offers the ability to execute SQL queries over the API. You can utilize the following steps to execute SQLite queries:1
Create a sample SQLite database
Create a simple SQLite database and populate it with sample data. Note that this is just a sample schema and you can write your own schema
as per the SQLite guideIf you have sqlite3 installed, you can run this locally using sqlite3 to convert your You can also utilize python scripts to convert your
sql schema into an sqlite file:schema.sql file into a db.sqlite file.2
Prepare Files for API Request
The Fermion API requires:This script will provide you with a
- A ZIP file containing your
db.sqlitefile (Base64URL encoded)
db.sqlite file in the same folder when you run this scriptdb.zip file and another file called encoded.txt, which will have the base64URL encoded string of the db.zip file.You can utilize this string while making the API request.3
Make the API Request
Once you have the encoded SQL and ZIP file, you can now execute SQL queries via the Request DSA code execution [batch] endpoint.
Note that you also have to base64URL encode the source code and add the encoded string to the request for the This
sourceCodeAsBase64UrlEncoded propertyYou can take help of the following json schema while setting up your own requests for SQL executions.POST request will return a list of task IDs which you can utilize while retrieving the execution results.4
SQLite test cases
SQLite can produce output in multiple formats (up to 14), but Fermion’s API uses the
Here’s an example:To get the expected output for your own query against your own database,
create a file called script.sql that has the solution query, and run the following command locally on your system:This command will print the output in the same list format that Fermion expects.
You can then take this exact output, encode it using Base64URL, and include it in your API request under:
list mode format for evaluating SQL output.In list mode, each column value is separated by a | (pipe), and each row appears on a new line.Here’s an example:
5
Retrieve results
You can utilize the task IDs received above to retrieve the results of DSA code execution
- Poll results via Get DSA code execution result [batch]
- Receive a webhook automatically if you specified
callbackUrlOnExecutionCompletionLearn more about this here
Best practices
- Ensure the ZIP file only contains
db.sqlite, not folders or other files. - Always use Base64URL, not standard Base64.
