Websqlbrowse
Web-based SQL Database Browser
websqlbrowse@headricksoftware.com
Copyright (C) 1998, 1999 Headrick Software Development
http://www.headricksoftware.com
Licensing information: http://www.headricksoftware.com/legal/
Readme file version beta-0.70
10/17/99
1. Version Notes
The is a beta release of Websqlbrowse. The program itself is quite
functional at this stage however new features are being implemented and most
documentation has yet to be written. Before you consider installing this
software, please verify that you have the most current version at http://www.headricksoftware.com/websqlbrowse.html.
Feel free to email websqlbrowse@headricksoftware.com
with any installation or configuration questions.
Source code contributions are also welcome at the same address.
New in version 0.70 is a feature written by contributing developer E. Genov
that allows a SQL script to be executed from Websqlbrowse and its results used.
Note the new configuration options and updated example.
2. Installation Instructions
3. Configuring Websqlbrowse
To browse a database table with Websqlbrowse you must first create an HTML
template that will POST the necessary parameters to the Websqlbrowse CGI.
Each parameter may be included as a hidden INPUT tag (i.e.
<INPUT TYPE="HIDDEN" NAME="parameter" VALUE="value">).
Alternatively, some parameters may be included in a server-side
configuration file. This speeds up pages loads by not passing around static
data such as table name, color preferences, etc. The format of the
server-side file is one entry per line consisting of "parameter = value". Do
not word-wrap a single parameter entry to more than one line.
Blank lines and lines starting with a hash sign (#) are ignored. Additional
information
on how to configure Websqlbrowse is available on the website. Each
parameter is listed and described below. Required parameters are required
in order for Websqlbrowse to function properly. In Websqlbrowse crashes,
include the parameter "wsqlb.debug" for more information. The most likely
cause of a crash is the omission of a necessary parameter. Future revisions
will handle this more gracefully.
mv websqlbrowse-VERSION /tmp
cd /tmp
tar -zxvf websqlbrowse-VERSION.tar.gz
cd websqlbrowse-VERSION
| Variable | Required? | Description |
| wsqlb.paramfile | NO |
This parmeter allows for the inclusion of any and all template variables in
a server-side template file. This greatly increases speed of page loads by
not including so much redudant data in the transmission. The format of this
file is simply "parameter = value", one parameter per line. Blank lines or
lines that begin with a hash sign (#) are ignored.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.paramfile" VALUE="/usr/local/wsqlb/db1.wsqlb"> this parameter cannot be placed in a server-side file (it defines the server side file). |
| wsqlb.debug | NO |
If this parameter is included, the existence of all required parameters
will be forced. This slows things down a bit, but could be useful in
the program crashes example: <INPUT TYPE="HIDDEN" NAME="wsqlb.debug" VALUE="TRUE"> or, server-side: wsqlb.debug = TRUE |
| wsqlb.action | YES |
must be one of the following: "list" -- list many records in a browse format) "detail" -- detail information about one record "edit" -- edit a record "update" -- update a record after editing "new" -- generate a blank form for a new record "insert" -- insert a record after entered in new form "delete" -- delete a record In general, start with "list" Lists have buttons to perform the other tasks. example: <INPUT TYPE="HIDDEN" NAME="wsqlb.action" VALUE="list"> this parameter should not be placed in the server-side file. |
| wsqlb.table | YES |
The name of the database table you are accessing.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.table" VALUE="Contacts"> or, server-side: wsqlb.table = Contacts |
| wsqlb.title | NO |
An optional <TITLE> tag.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.title" VALUE="My Contacts"> or, server-side: wsqlb.title = My Contacts |
| wsqlb.prikey | YES |
The primary key for this table.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.prikey" VALUE="ContactID"> or, server-side: wsqlb.prikey = ContactID |
| wsqlb.defprikey | YES |
Must be either "nextavailable" or "FALSE"
if the primary key is an integer (ie RecordID)
"nextavailable" will give new records the next
available primary key. This is highly
recommended.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.defprikey" VALUE="nextavailable"> or, server-side: wsqlb.defprikey = nextavailable |
| wsqlb.itemid | SOMETIMES |
Specifies the primary key if accessing a
specific record (ie edit, detail, etc.)
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.itemid" VALUE="34"> this parameter should not be placed in the server-side file. |
| wsqlb.font | YES |
The font to use.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.font" VALUE="Helvetica,Arial"> or, server-side: wsqlb.font = Helvetica,Arial |
| wsqlb.fontsize | NO |
The font size to use.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.fontsize" VALUE="3"> or, server-side: wsqlb.fontsize = 4 |
| wsqlb.bgcolor | YES |
The background color to use.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.bgcolor" VALUE="#FFFFFF"> or, server-side: wsqlb.bgcolor = #FFFFFF |
| wsqlb.headercolor | YES |
The color to use for the column headers in a list view.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.headercolor" VALUE="#0000FF"> or, server-side: wsqlb.bgcolor = #0000FF |
| wsqlb.headerbg | YES |
The background color to use in the above mentioned column headers.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.headerbg" VALUE="#000000"> or, server-side: wsqlb.bgcolor = #000000 |
| wsqlb.labelcolor | YES |
The color to use on field labels in new/detail/edit view.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.labelcolor" VALUE="#0000FF"> or, server-side: wsqlb.labelcolor = #0000FF |
| wsqlb.linkcolor | YES |
The color to use for links (ie list entries).
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.linkcolor" VALUE="#0000FF"> or, server-side: wsqlb.linkcolor = #0000FF |
| wsqlb.textcolor | YES |
The default text color.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.textcolor" VALUE="#000000"> or, server-side: wsqlb.textcolor = #000000 |
| wsqlb.vinfocolor | YES |
The color for the version information.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.vinfocolor" VALUE="#0000FF"> or, server-side: wsqlb.vinfocolor = #0000FF |
| wsqlb.rowcolor | NO |
A background color for each cell in the list view.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.rowcolor" VALUE="#AAAAAA"> or, server-side: wsqlb.rowcolor = #AAAAAA |
| wsqlb.saveimage | NO | A button image (optional). |
| wsqlb.editimage | NO | A button image (optional). |
| wsqlb.backimage | NO | A button image (optional). |
| wsqlb.newimage | NO | A button image (optional). |
| wsqlb.deleteimage | NO | A button image (optional). |
| wsqlb.enabledelete | NO |
If defined, delete is enabled and delete buttons are presented (By default,
delete is turned off). example: <INPUT TYPE="HIDDEN" NAME="wsqlb.enabledelete" VALUE="TRUE"> or, server-side: wsqlb.enabledelete = TRUE Note that the value doesn't matter. Don't include this variable set to FALSE to disable delete. To disable record deletion, just don't include the enabledelete variable at all. |
| wsqlb.enableedit | NO |
Set to FALSE to disable the edit button. This option defaults to TRUE.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.enableedit" VALUE="TRUE"> or, server-side: wsqlb.enableedit = TRUE |
| wsqlb.enablenew | NO |
Set to FALSE to disable the new button. This option defaults to TRUE.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.enablenew" VALUE="TRUE"> or, server-side: wsqlb.enablenew = TRUE |
| wsqlb.listfields | YES |
A comma delimited list of all the table fields to display in list view.
Put spaces after each comma. example: <INPUT TYPE="HIDDEN" NAME="wsqlb.listfields" VALUE="ContactID, Name, Email, RelationShipID"> or, server-side: wsqlb.listfields = ContactID, Name, Email, RelationShipID |
| wsqlb.listfields.types | YES |
A comma delimited list of the types of the fields listed in the listfields parameter.
Possible types are: {int, string, bool, url, lookup, file, date, qdate}. lookup types
require lookup information in the following format: lookup:Table/LookupField/DisplayField.
For example, if you have a "Relationship" field in your Contacts table that takes an integer
value which corresponds to the RelationShipID field in a "Relations" table, but you want
to display the "RelationDescription" field on the browse, you would use something like:
lookup:Relations/RelationID/RelationDescription. example <INPUT TYPE="HIDDEN" NAME="wsqlb.listfields.types" VALUE="int, string, string, lookup:RelationShips/RelationShipID/RelationShipName"> or, server-side: wsqlb.listfields.types = int, string, string, lookup:RelationShips/RelationShipID/RelationShipName |
| wsqlb.columntitles | NO |
A comma delimited list of text to display for each column in the list view.
If unspecified, the field names are used.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.columntitles" VALUE="ID, Name, Email, Relationship Type"> or, server-side: wsqlb.columntitles = ID, Name, Email, Relationship Type |
| wsqlb.columnalign | NO |
A comma delimited list of the ALIGN type to use for each column in the
list view (i.e. LEFT, RIGHT, CENTER).
If unspecified, the columns are left-justified (LEFT).
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.columnalign" VALUE="CENTER, LEFT, CENTER, RIGHT"> or, server-side: wsqlb.columnalign = CENTER, LEFT, CENTER, RIGHT |
| wsqlb.columnwidth | NO |
A comma delimited list of the WIDTH to use for each column in the
list view.
If unspecified, the WIDTH parameter is not included.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.columnalign" VALUE="10%, 15%, 15%, %60"> or, server-side: wsqlb.columnalign = 10%, 15%, 15%, %60 |
| wsqlb.detailfields | YES |
A comma delimited list of all the fields to be present in the detail/edit/new record views.
example: <INPUT TYPE="HIDDEN" NAME="wsqlb.detailfields" VALUE="ContactID, Name, Email, WebURL, Phone, GenderID, RelationShipID, Notes"> or, server-side: wsqlb.detailfields = ContactID, Name, Email, WebURL, Phone, GenderID, RelationShipID, Notes |
| wsqlb.detailfields.types | YES |
A comma delimited list of all the field types of the fields in the
detailfields parameter. example: <INPUT TYPE="HIDDEN" NAME="wsqlb.detailfields.types" VALUE="int, string, string, url, string, lookup:Genders/GenderID/GenderName, lookup:RelationShips/RelationShipID/RelationShipName, file"> or, server-side: wsqlb.detailfields.types = int, string, string, url, string, lookup:Genders/GenderID/GenderName, lookup:RelationShips/RelationShipID/RelationShipName, file |
| wsqlb.newdefaults | YES |
A comma delimited list of default values for new records. You can use special variables
such as "$nothing" and "$today." If you defined the defprikey
parameter as "nextavailable", you can also use the "$nextid" value, which will be the
next integer valued primary key for this new record. This is useful if you, for instance,
have a notes file for each record located somewhere like "/notes/contactX.notes" where X is
the primary key for that contact. example: <INPUT TYPE="HIDDEN" NAME="wsqlb.newdefaults" VALUE="$nextid, $nothing, $nothing, NONE, $nothing, 1, 1, /var/lib/httpd/wsqlb/notes/contact$nextid.notes"> or, server-side: wsqlb.newdefaults = $nextid, $nothing, $nothing, NONE, $nothing, 1, 1, /var/lib/httpd/wsqlb/notes/contact$nextid.notes |
| wsqlb.numlimiters | SOMETIMES |
If the action variable is set as "list", this is an integer value of the number of
statements restricting the SELECT query. It may be 0. For each limiter, a
"wsqlb.limitfield" and "wsqlb.limitrequire" field is required. example: <INPUT TYPE="HIDDEN" NAME="wsqlb.numlimiters" VALUE="2"> this parameter should not be placed in the server-side file. |
| wsqlb.limitfieldX | SOMETIMES |
For each restricting statement (as indicated by the numlimiters parameter), you need to
specify which field you are dealing with. example: <INPUT TYPE="HIDDEN" NAME="wsqlb.limitfield1" VALUE="RelationShipID"> <INPUT TYPE="HIDDEN" NAME="wsqlb.limitfield2" VALUE="GenderID"> this parameter should not be placed in the server-side file. |
| wsqlb.limitrequireX | SOMETIMES |
For each restricting statement (as indicated by the numlimiters parameter), you need to
specify what restriction you are dealing with. This should be a fragment
that uses "=" "<" ">" or other valid SQL syntax. For example, if your
wsqlb.limitfield1 is set to "RelationShipID" and you want the RelationShipID
field for the results returned to be "1", your wsqlb.limitrequire1 field
would be "= 1". Note that there are some special variables you can use in
the limitrequire parameter. For example, if you had a date field and you
wanted to get records added before today, you would set the respective
limitrequire field to "< '$today'". example: <INPUT TYPE="HIDDEN" NAME="wsqlb.limitrequire1" VALUE="= 1"> <INPUT TYPE="HIDDEN" NAME="wsqlb.limitrequire2" VALUE="= 1"> this parameter should not be placed in the server-side file. |
| wsqlb.orderby | SOMETIMES |
For a "list" action, specifies by which fields to order the query. example: <INPUT TYPE="HIDDEN" NAME="wsqlb.orderby" VALUE="Name"> or, server-side: wsqlb.orderby = Name |
| wsqlb.nolinkul | NO |
If this variable is defined and set as "TRUE", a STYLE tag will be included so that
links are not underlined. This makes list views more readable. example: <INPUT TYPE="HIDDEN" NAME="wsqlb.nolinkul" VALUE="TRUE"> or, server-side: wsqlb.nolinkul = TRUE |
Parameters for additional functionality created by E. Genov:
A simple example:
Consider a Contacts database created with the following SQL script:
Let's say we want to maintain this database using Websqlbrowse.
We would first create a server side configuration file with the static
settings:
Assume the above file is created as /var/lib/httpd/wsqlb/contacts.wsqlb
Assume the above file is created as /var/lib/httpd/wsqlb/ContactQ.wsqlb
Assume the above file is created as /var/lib/httpd/wsqlb/relations.wsqlb
Assume the above file is created as /var/lib/httpd/wsqlb/QR.wsqlb.
The HTML file used to launch Websqlbrowse would be:
4. Support/Customizations
Support and customizations are available. Contact
websqlbrowse@headricksoftware.com.
5. Warranty (or lack thereof)
The product is provided "as is," Headrick Software Development makes no
warranties, express or implied, including but not limited to warranties of
merchantability or fitness for any particular purpose, or that the use of
the product will not infringe any third party patents, copyrights,
trademarks, or other rights.
Headrick Software Development will not be liable for any direct, indirect,
special, or consequential damages associated with the use of the product.
Please see the licensing information for more information
(http://www.headricksoftware.com/legal/).
create table Contacts (
ContactID int primary key,
Name char(100),
Email char(50),
WebURL char(50),
Phone char(20),
GenderID int,
RelationShipID int,
Notes char(50),
LastUpdated timestamp
);
create table Genders (
GenderID int primary key,
GenderName char(20)
);
create table RelationShips (
RelationShipID int primary key,
RelationShipName char(50)
);
create table ViewRelation(
ID smallint,
RelationShip char(50),
Quantity smallint
);
insert into Genders (GenderID, GenderName) VALUES(1, 'Male');
insert into Genders (GenderID, GenderName) VALUES(2, 'Female');
insert into RelationShips (RelationShipID, RelationShipName) VALUES(1, 'Friend');
insert into RelationShips (RelationShipID, RelationShipName) VALUES(2, 'Family');
insert into RelationShips (RelationShipID, RelationShipName) VALUES(3, 'Business');
#
# Websqlbrowse parameter file for Contacts table
#
wsqlb.debug = TRUE
wsqlb.table = Contacts
wsqlb.title = My Contacts
wsqlb.prikey = ContactID
wsqlb.defprikey = nextavailable
wsqlb.font = Helvetica,Arial
wsqlb.fontsize = 4
wsqlb.nolinkul = TRUE
wsqlb.bgcolor = #000000
wsqlb.headercolor = #FFFFFF
wsqlb.headerbg = #0000FF
wsqlb.labelcolor = #0000FF
wsqlb.linkcolor = #FFFFFF
wsqlb.textcolor = #0000FF
wsqlb.vinfocolor = #00FF00
wsqlb.listfields = ContactID, Name, Email, RelationShipID
wsqlb.listfields.types = int, string, string, lookup:RelationShips/RelationShipID/RelationShipName
wsqlb.detailfields = ContactID, Name, Email, WebURL, Phone, GenderID, RelationShipID, Notes
wsqlb.detailfields.types = int, string, string, url, string, lookup:Genders/GenderID/GenderName, lookup:RelationShips/RelationShipID/RelationShipName, file
wsqlb.newdefaults = $nextid, $nothing, $nothing, NONE, $nothing, 1, 1, /var/lib/httpd/wsqlb/notes/contact$nextid.notes
#
# Websqlbrowse parameter file for ViewRelation table
#
wsqlb.debug = TRUE
wsqlb.table = ViewRelation
wsqlb.title = My Contacts
wsqlb.prikey = ID
wsqlb.defprikey = nextavailable
wsqlb.font = Helvetica,Arial
wsqlb.fontsize = 4
wsqlb.nolinkul = TRUE
wsqlb.bgcolor = #000000
wsqlb.headercolor = #FFFFFF
wsqlb.headerbg = #0000FF
wsqlb.labelcolor = #0000FF
wsqlb.linkcolor = #FFFFFF
wsqlb.textcolor = #0000FF
wsqlb.vinfocolor = #00FF00
wsqlb.listfields = RelationShip, Quantity
wsqlb.listfields.types = string, int
wsqlb.columnalign = RIGHT, LEFT
wsqlb.enablenew = FALSE
wsqlb.enableedit = FALSE
wsqlb.detailfields = ID, RelationShip, Quantity
wsqlb.detailfields.types = int, string, int
wsqlb.newdefaults = $nextid, $nothing, $nothing
#
# Websqlbrowse parameter file for RelationShips table
#
wsqlb.debug = TRUE
wsqlb.table = RelationShips
wsqlb.title = My Relations
wsqlb.prikey = RelationShipID
wsqlb.defprikey = nextavailable
wsqlb.font = Helvetica,Arial
wsqlb.fontsize = 4
wsqlb.nolinkul = TRUE
wsqlb.bgcolor = #000000
wsqlb.headercolor = #FFFFFF
wsqlb.headerbg = #0000FF
wsqlb.labelcolor = #0000FF
wsqlb.linkcolor = #FFFFFF
wsqlb.textcolor = #0000FF
wsqlb.vinfocolor = #00FF00
wsqlb.listfields = RelationShipID, RelationShipName
wsqlb.listfields.types = int, string
wsqlb.detailfields = RelationShipID, RelationShipName
wsqlb.detailfields.types = int, string
wsqlb.newdefaults = $nextid, $nothing
#
# SQL script file for ViewRelation table
#
# calculates relationship number
delete from ViewRelation;
insert into ViewRelation(ID,RelationShip,Quantity)
select 1,'&1',count(*)
from RelationShips R, Contacts C
where C.RelationShipID = R.RelationShipID
and R.RelationShipName = '&1';
# end
<HTML>
<HEAD>
<TITLE>Contacts Database</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<FORM NAME="Contacts" METHOD="POST" ACTION="/cgi-bin/wsqlb.cgi">
<INPUT TYPE=hidden NAME="wsqlb.paramfile" VALUE="/var/lib/httpd/wsqlb/relations.wsqlb">
<INPUT TYPE=hidden NAME="wsqlb.relparamfile" VALUE="/var/lib/httpd/wsqlb/contacts.wsqlb">
<INPUT TYPE=hidden NAME="wsqlb.relparent1" VALUE="RelationShipID">
<INPUT TYPE=hidden NAME="wsqlb.relchild1" VALUE="RelationShipID">
<INPUT TYPE=hidden NAME="wsqlb.relnumcolumn" VALUE="1">
<INPUT TYPE=hidden NAME="wsqlb.orderby" VALUE="RelationShipName">
<INPUT TYPE="HIDDEN" NAME="wsqlb.action" VALUE="list">
<INPUT TYPE="HIDDEN" NAME="wsqlb.numlimiters" VALUE="0">
<INPUT TYPE="submit" VALUE="View Contacts">
</FORM>
<DIV align="center">
<BR><HR>
<TABLE width="500">
<FORM NAME="Relations" METHOD="POST" ACTION="/cgi-bin/wsqlb.cgi">
<INPUT TYPE=hidden NAME="wsqlb.paramfile" VALUE="/var/lib/httpd/wsqlb/ContactQ.wsqlb">
<INPUT TYPE=hidden NAME="wsqlb.SQLscript" VALUE="/var/lib/httpd/wsqlb/QR.sql">
<INPUT TYPE=hidden NAME="wsqlb.action" VALUE="list">
<INPUT TYPE=hidden NAME="wsqlb.numlimiters" VALUE="0">
<TR>
<TD>How many </TD>
<TD>
<SELECT name="wsqlb.SQLarg1" size="1">
<OPTION value="Friend" selected>friend
<OPTION value="Family">family
<OPTION value="Business">business
</SELECT>
</TD>
<TD> relations are there</TD>
<TD><INPUT TYPE="submit" VALUE=" ? "> </TD>
</TR>
</FORM>
</TABLE>
</DIV>
</BODY>
</HTML>
webmaster@headricksoftware.com