Implemented Interactive REPL-Shell
You can now type tempest repl <DATA_DIR> to create/open a database at the specified path.
After doing so, you will be put in an interactive shell. The shell has different command built-in commands, all starting with a .:
-
.help | .hshow help menu -
.quit | .qterminate the REPL session -
.databases | .dbslist all databases -
.tables <database>list all tables, optionally scoped to a database -
.types <database>list all types, optionally scoped to a database
Aside from the built-in commands, you can execute valid TQL statements. If you happen to make a syntax error, it will show nice error messages using the span data I collect inside of the parser. The formatted error report is then rendered using the ariadne crate, so I don’t have to do all that ugly string interpolation myself.
Here is a list of queries you can try out:
-
create database main;: create a new database calledmain -
create type main.User { id: Int64, username: String }: create a type calledUserinside of the databasemain. The fields areid, which is a 64 bit integer, andusername, which is a String. -
create table main.users : main.User { primary key (id) };: create a table calledusersinside of the databasemainwith the typeUserfrom the same database and with the fieldidas the primary key. -
insert into main.users { id: 42, username: "John" };: insert an entry into the tableusersinside of the databasemain. The entry has the value42for the fieldid, and the value"John"for the fieldusername. -
select * from main.users;: select every column of all the entries from the tableusersinside of the databasemain. Alternatively, you can supply specific fields, instead of*, to only get out those fields.
Not sure what I’ll be doing next, but it will be fun!
Log in to leave a comment