Programs
Db7 Source Code
 previous   up   next 

Db7 is a Database Inspector. The Database Inspector provides access to MySQL, MariaDB, SQLLite, PostgreSQL, Oracle, Firebird, Interbase, Db2 and SQL Server databases. Databases can also be accessed via the ODBC interface. Db7 uses a browser as user interface. If the browser is not running it will be started. If the browser is already running a new tab is opened, which contains a dialog to do a database login.

Usage

Db7 can be executed from the commandline with:

s7 db7

At the Db7 login page the database type can be selected. The name of the database can be given in one of these forms:

  • host:port/dbName
  • host/dbName
  • dbName

The user name and the password can be entered also.

After a successful login SQL statements can be executed. The SQL statements are sent to the database. So it depents on the database, if a SQL statement is accepted and executed. Only a few things are independent of the database:

  • Strings in a SQL statement are enclosed in apostrophes (e.g. 'abc').
    • A string consists of all characters between the enclosing apostrophes.
    • Apostrophe characters (') in a string must be doubled to get one apostrophe character in the string.
  • Comments in a SQL statement start with /* and end with */.
  • Line comments in a SQL statement start with -- and end with a newline character ('\n').
  • Table and field names can be enclosed in double quotes (e.g. "aTable").
    • This way a table or field name can contain spaces or other characters, that are normally not allowed.
    • Double quotes in a quoted name must be doubled (several databases do not allow double quotes in names).

Instead of executing a SQL statement it is also possible to get a catalog of tables defined in the database. In the catalog it is possible to get the contents of a table.

How the user interface works

The library browser.s7i defines a function to open a browser. The browser is instructed to load a page from a specified port. The program listens at this port and answers the HTTP request. Pressing a button in the browser triggers a new request that is again answered by the program. The program uses the library cgidialog.s7i to create HTML to answer the HTTP request. In the Seed7 program dialog elements are defined. HTML and HTTP are encapsulated in the library, such that the programmer does not need to handle HTML or HTTP.


Database login

Possibility to execute SQL statements

Catalog of tables

Content of a table

 previous   up   next