About Configuration For Database Use

To configure Gen for using the database-related commands, you need to do the following four steps:

  1. Set up a database connection.
  2. Set name of the database connection to use.
  3. Set the name of the globals table to use (optional).
  4. Create the globals table.

Note that Gen is currently set only for SQLite usage and does not use TDBC.

1. Setting up a database connection

This is simply the command sqlite3 dbcmd database-name, for instance: sqlite3 mydb c:/my.db.

Note that with Gen, you are responsible for opening and closing connections and telling Gen what connection to use (see next section).

2. Setting name of database connection to use.

Here you only have to give Gen the dbcmd you set up in the previous step. You want to set the GenNS::DatabaseName variable. For instance, set GenNS::DatabaseName mydb.
This is used whenever Gen has to interact with a database. Gen does not have capabilities to change around connections on a per-command basis (perhaps in the future we will add flags for that). However, you can yourself do a set GenNS::DatabaseName again to change the connection.

3. Setting the name of the globals table to use

If you want Gen to use something other than "globals" for the name of its globals table, then you set GenNS::GlobalsTable. For instance, you could do set GenNS::GlobalsTable my_globals or set GenNS::GlobalsTable the_globals, etc.

4. Creating the globals table

To do this you can run the following code:

RunSqlCreateTable globals {id {integer primary key} desc text intvalue integer realvalue real textvalue text}

Note that you can, alternatively edit gen-config.tcl by hand to set the variables (though you must take care when you upgrade to a new version of Gen, since those values may be overwritten).