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 You can utilize this string while making the API request.
- A ZIP file containing your
db.sqlite
file (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.The ZIP must contain exactly one file named
db.sqlite
: the API expects this name. Do not rename it to anything else inside the ZIP archive.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
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
callbackUrlOnExecutionCompletion
Learn 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.