The REPL

Delia includes a REPL command-line application. You can use it to view and troubleshoot the database. And to try out Delia features in a convenient interactive way.

Starting the REPL

The DeliaRepl class takes two parameters:

  • a ConnectionInfo object that defines the database to connect to.
  • a base directory, where delia source files can be loaded from
ConnectionInfo info = ConnectionBuilder.dbType(DBType.H2).connectionString(H2ConnectionHelper.getTestDB()).build();
DeliaRepl repl = new DeliaRepl(info, BASE_DIR);
repl.run();

You should see:

Delia REPL - dbType: H2

(no session)> 

Using the REPL

Begin by running a Delia source that defines the types in your database. Let's assume there is a ‘myproject.txt’ file in the base dir. Run it using the ‘run’ command:

(no session)> run myproject.txt
[1] reading: myproject.txt
[1] types: Customer
[1] running migration with 1 steps:
[1]   create-table: Customer
OK - session 'myproject' created.```

The prompt changes to “myproject>” to indicate that a session has been started. You are now connected to the database.

You can run any Delia statement in the REPL: Let's query for a customer by primaryKey 1002

myproject> Customer[1002]
result: (Customer) = {
 id:1002
 firstName:'Susan'
 lastName:'Smith'
}
OK

Let's look at REPL Commands