Airsequel’s SQL workbench lets you execute arbitrary SQL queries on your SQLite database.
As seen in the screenshot above, airsequel provides OpenAI integration for query generation. Moreover, you can work on multiple queries simultaneously by creating multiple tabs:
As seen in the pictures above, the query can be saved as a new or existing view using the buttons on the bottom right. By default, the view will now appear in the “tables” tab, but a special “views” tab can be enabled in the settings:
Check out the pricing page for all limitations of the Free edition.
In order to support more elaborate types than just the basic SQL types, we came up with a specification on how to extend SQLite with extra datatypes in a standard conformant way.
The basic idea is to use suffixes like e.g. TEXT_EMAIL to specify more refined types. Since SQLite’s type affinity will treat this as a TEXT column, it works in a backwards compatible way.
When editing entries via the GUI, Airsequel will provide specialized input fields for the given type. For instance, “color” columns can be edited using a color picker:
Interactive Editing
Airsequel provides comprehensive interactive editing capabilities. The most common operations are presented in the list below:
Change the name or description of a database
The name and description for a database can be changed by clicking on the respective “edit” icon in the “Database” tab:
Furthermore, the description can be automatically generated using the built in OpenAI integration:
Database descriptions can make use of certain markdown features (italic and bold text, lists, links, headings, …):
Create a table
New tables can be created by using the “+” to the right of the list of existing tables from the tables tab:
Rename / Delete / Export a table
Click on the arrow next to the name of the table in the “tables” tab:
Change table description
Click on the arrow next to the name of the table in the “tables” tab.
Airsequel also provides OpenAI integration for generating table descriptions:
Create a column
Click on the “+” icon at the end of the list of columns on one of the tables in the “tables” tab:
Alternatively, columns can be created at arbitrary positions by clicking on the arrow icon next to an existing column and choosing “insert left/right”:
Delete / Rename / Hide (collapse) column
Click on the arrow icon next to the column in “tables” tab:
In the case of the “Collapse” option, the process can be reversed by clicking the “Expand” option which appears in it’s place.
Set all entries of column to the default value
Click on the arrow icon next to the column in the “tables” tab and then choose “Empty all cells” (in the case of columns which can be NULL) or “Default all cells” (in the case of NOT NULL columns):
Reorder columns
The order of a table’s columns can be changed by dragging and dropping the two sets of dots at the top of a column in the “tables” tab:
Delete an arbitrary set of rows
Rows under a table in the “tables” view can be selected by checking the box on their left:
Alternatively, all rows within a table can be selected by checking the box at top-left corner of the table:
The aforementioned checkboxes can be unchecked to unselect the rows in question. Once at least one row is selected, the “delete” icon at the top-left corner of the table can be clicked to delete the selected rows.
Create a row
Rows can be created by clicking the “+” button at the bottom of their table:
Edit a cell
Editing a cell is as simple as clicking on it and then typing it’s new value!
Certain types offer specialized inputs. For example, colors can be chosen using a color picker:
SQL API Usage
The SQL API is only available in the Enterprise Edition.
SQLite does not allow OFFSET without a LIMIT clause. To work around this restriction, simply set the LIMIT to -1:
sql
SELECT*FROM table_name
LIMIT-1OFFSET1
Only update value if it’s not NULL
This is especially useful if you’re passing the value from the code calling your SQL query. For example here it only updates the name value (passed in via :name) if it is not NULL.
sql
UPDATE users
SET name =COALESCE(:name, name)WHERE rowid ==2
To better work with deeply nested objects and arrays, it’s recommended to flatten the JSON before inserting it into a cell. E.g. with github.com/hughsk/flat.
Generation
Generate a table with numbers from 1 to 10
sql
WITHRECURSIVEten(x)AS(SELECT1UNIONALLSELECT x +1FROM ten WHERE x <10)SELECT*FROM ten;
Generate a table random_data with x rows of random entries
WITHRECURSIVEsplit(id, csv_line, rest)AS(SELECT id,'', csv || x'0a'FROM csvs
UNIONALLSELECT
id,substr(rest,0,instr(rest, x'0a')),substr(rest,instr(rest, x'0a')+1)FROM split WHERE rest !='')SELECT id, csv_line
FROM split
WHERE csv_line !='';
Get the last NOT NULL value in a group
sql
CREATETABLEtest(id, val);INSERTINTOtest(id, val)VALUES('a',NULL),('a',123),('a',456),('a',NULL),('b',789),('b',12),('b',NULL);SELECT id, val FROM(SELECT
id,
val,ROW_NUMBER()OVER(PARTITIONBY id ORDERBYROWIDDESC)AS row_number
FROM test
WHERE val ISNOTNULL)WHERE row_number =1;
Or with an additional aggregate function:
sql
SELECT*FROM(SELECT
id,FIRST_VALUE(val)OVER(PARTITIONBY id ORDERBYROWIDDESC)AS row_number
FROM test
WHERE val ISNOTNULL)GROUPBY id;
Or only with an aggregate function instead of a window function:
sql
WITHtest_grouped(id, val_array)AS(SELECT id,json_group_array(val)FILTER(WHERE val ISNOTNULL)FROM test
GROUPBY id
)SELECT
id,
val_array ->>(json_array_length(val_array)-1)AS val
FROM test_grouped;
yields
id
val
a
456
b
12
Automatically set a random id after inserting a row
sql
CREATETRIGGER insert_random_id_after_insert_users
AFTERINSERTON users
BEGINUPDATE users
--32 hex characters long random id
SET random_id =lower(hex(randomblob(16)))WHERE rowid ==NEW.rowid;END
If it should be possible to set the random ID during insert, check if NEW.random_id is empty before overwriting it.
Convert table of cumulative values to delta values
As we can't calculate a delta amount for the first year, we must omit it from the result table. SQLite requires a LIMIT clause when using OFFSET. To work around this limitation, we can set the LIMIT to -1.