3469
3521
I set this when looking at other people's mail, such as my wife's account.
3470
3522
I don't want her mail sent somewhere else because it matches one of my filter rules.
3524
<H3 align=center> <A NAME=sqlb> Building edbrowse with Database Access </A> </H3>
3526
If you simply type make, you get edbrowse, with no database interface.
3527
Two other targets support database access.
3528
Run either `make edbrowseodbc' or make `edbrowseinf'.
3529
The former uses odbc to access just about any sql database,
3530
and the latter uses the
3531
<A HREF=http://www.informix.com>Informix</A> interface.
3532
If you would like to test the odbc interface,
3533
or write a new interface, e.g. for Oracle or mysql,
3534
I will be eternally grateful.
3535
You are basically implementing the interface described in dbapi.h,
3536
using the C database development toolkit provided by the vendor.
3537
The easiest way to proceed is to copy one of the two files that is already there,
3538
dbinfx.ec or dbodbc.c, and make changes as necessary.
3540
<H3 align=center> <A NAME=rtb> Reading Tables </A> </H3>
3542
When a file name is of a certain format, with the http:// in front etc,
3543
it is deemed to be a url.
3544
Edbrowse does not look on your computer for the file; it goes out to the internet.
3545
Similarly, when the file name has a certain format,
3546
it is assumed to be a table or view in the database.
3547
If you have a table called customers, you follow it up with a right bracket.
3553
This allows you to bring in the entire table,
3554
or portions thereof, one row per line, with fields delimited by pipes.
3555
If the result looks like a bunch of numbers and pipes,
3556
and you have forgottten the structure of the table,
3557
use the sc (show columns) command.
3558
The output might look like this.
3560
<P><PRE><font size=3 face=Arial,Helvetica,sans-serif>Table customers, 536281 rows
3571
The first column is a unique number that designates this particular customer.
3572
After all, two customers could have the same first and last name,
3573
and even the same birthdate.
3574
Serial numbers are <em>always</em> a good idea,
3575
and that usually becomes the primary key.
3576
This is indicated by a star, just before the column name.
3577
If edbrowse changes or deletes a record, the primary key is used.
3578
I assume, at all times, that the key determines a unique record in the database,
3579
and that each record appears at most once in an editing session.
3582
Note that edbrowse can support a primary key with two columns, such as a serial number and a modifier.
3583
I actually have some tables at work that look like this.
3586
The table syntax is more than just an identifier and a right bracket.
3587
You can follow the right bracket with a where clause.
3588
This is important if you don't want the entire table,
3589
especially if there are millions of rows.
3590
Here are some table commands and their meanings.
3595
Set the buffer up for the customers table, but don't fetch any rows.
3600
Fetch all the rows in the table.
3605
Fetch the customer whose serial number is 37.
3606
The primary key is assumed; your table has to have a primary key
3607
if you are going to use this syntax.
3612
Fetch the row whose first column is 37.
3617
Fetch the customers with serial numbers between 37 and 59 inclusive.
3622
Fetch the customers whose last name is Smith.
3625
customers]lastname=Smith
3630
customers]last=Smith
3632
Same as above.
3633
If the string uniquely gloms onto a column name, we're all set.
3636
customers]last=Barn*
3638
Fetch the customers whose last names begin with Barn.
3641
customers]birth=01/01/1960-12/31/1960
3643
Fetch the customers who were born in 1960.
3646
It is sometimes best to edit with a blank template, i.e. without a where clause.
3647
Then, you can read in whatever rows you like.
3648
Type an r before any of the strings shown above to read rows into your buffer.
3649
Note, you cannot read data from different tables into the same buffer,
3650
but you can switch to another editing session to look at another table,
3651
without losing the rows you are working on.
3654
When reading rows into a growing buffer, you can usually omit the table, since it has to be customers] every time.
3655
For instance, you can bring in customer #738 by typing `r customers]738' or `r 738'.
3658
If you want a clean slate, type `rf' to refresh the buffer.
3659
This brings you back to a template for the table, with no rows.
3660
WARNING - do not clear your buffer by deleting all the rows,
3661
as that will delete the corresponding entries in the database.
3662
This feature works just like directory mode -
3663
your edits are translated into actions in the real world, so be careful.
3664
Referential integrity will usually save you from this accidental delete disaster,
3665
if you routinely use this sql feature to link tables together,
3666
which is a good idea at many levels.
3669
Now, how about the seventh column in our example, the one called "picture"?
3670
This is the customer's picture, a jpg image that is in binary,
3671
and cannot be easily folded into an editing session.
3672
Instead, it is stored in another buffer,
3673
e.g. buffer 9, and this is indicated by <9>.
3674
You can switch to session 9 and save the file, or throw it away.
3677
2139|Fred|Flintstone|08/21/1969|M|foo@bar.bar.com|<9>
3680
To do anything with the database, your config file must specify
3681
the name of the database, the login, and the password.
3682
(The last two can sometimes be omitted, if they are inferred from your identity on the computer.)
3683
Here is how the line might look
3684
if you are tapping into the retail database, where the customers table resides.
3687
database = retail,mylogin,mypassword
3690
Although this cannot be changed on the fly, you can access other databases by vectoring through this one.
3691
For instance, you can read the parts table in the inventory database by calling up inventory:parts].
3692
This is standard sql syntax for looking at tables in another database;
3693
I just pass it through.
3695
<H3 align=center> <A NAME=insupd> Insert, Update, Delete </A> </H3>
3697
Adding database rows is substantially different from adding text.
3698
Since a row may contain a dozen fields, and you may not remember what goes where,
3699
edbrowse prompts you for each field in turn.
3700
It also checks the integrity of each field as you go,
3701
e.g. a date has to look like mm/dd/yyyy etc.
3702
If a row cannot be added because of a database error,
3703
edbrowse prints the error,
3704
and data entry continues;
3705
giving you a chance to reenter the row.
3706
Data entry stops when you enter a period all by itself,
3707
no matter what field you are on.
3708
The rows that were entered successfully will be present in your buffer,
3709
and the current line is the last entered row.
3710
Note that blobs cannot be entered at this time.
3713
Use the substitute command to update a row.
3714
Make sure you don't accidentally introduce an additional pipe, or remove a pipe.
3715
Key columns cannot be modified.
3716
If you are updating many rows with one command,
3717
through a range or through g//s,
3718
and an error occurs while updating the database,
3719
substitution stops in its tracks.
3720
The editing session will reflect the database,
3721
with some rows changed and others untouched.
3722
There are many reasons for these update errors, including datatype mismatch
3723
(e.g. pushing an integer into a date field), and check constraints
3724
(e.g. putting J in for sex, instead of M or F).
3725
If you have any say in the database design,
3726
apply check constraints wherever they make sense.
3727
They will protect you from erroneous substitutions, wich would produce inconsistent updates.
3730
Delete works as you would expect; delete a row,
3731
and the corresponding entry disappears.
3732
There is no undo command.
3733
It couldn't be done in any case, since you may have selected only part of the row (see below),
3734
and I wouldn't have all the data to put the row back.
3735
As mentioned before, referential integrity should be employed wherever it makes sense.
3736
As a last check, I only let you delete 100 rows at a time.
3737
Be careful, and run regular backups.
3739
<H3 align=center> <A NAME=td> Table Descriptors </A> </H3>
3741
Suppose a table contains 100 fields.
3742
Displaying all those fields is awkward, to say the least.
3743
Sometimes you are interested in a group of 6 fields,
3744
and sometimes you are interested in another group of 8.
3745
You can set up virtual tables, similar to views, in your config file.
3746
The short name is the alias, and you can call up the table using this alias.
3747
It will contain only the columns you specify.
3748
Here are two descriptors for the aforementioned customers table.
3750
<P><PRE><font size=3 face=Arial,Helvetica,sans-serif>table {
3752
# cnm is my cryptic shorthand for customer name
3753
# I want to be cryptic here, cause I'm going to be typing this a lot.
3755
cols = custnum,firstname,lastname
3756
# Specify the primary key, in this case, the first column selected.
3762
# All I care about here is customer and birthdate.
3764
cols = birthdate,custnum
3770
When inserting a row through one of these descriptors,
3771
remember that you are only specifying a subset of the columns in the table.
3772
The other columns will be null, or they will take on their default values,
3773
as specified by the schema.
3774
If you receive a Not-Null error, it could be due to one of the other columns,
3775
which requires an entered value.
3776
It is usually safer to insert a row using the complete table.
3472
3778
<H3 align=center> <A NAME=end> Wrap up </A> </H3>
3474
3780
That concludes the user's guide.
3475
3781
As you can see, edbrowse is a difficult program to master, but an easy program to use.
3476
3782
I believe this is the key to success for any blind user or programmer.
3477
3783
One can certainly paste a screen reader on top of an existing 2 dimensional program
3478
such as emacs or lynx, and get "up and running" quickly,
3784
such as emacs or lynx, and get up and running quickly,
3479
3785
but to be truly competitive in the workplace, or efficient at home,
3480
3786
you need a <A HREF=http://www.eklhad.net/cli.html>command line interface</a>.
3481
3787
Edbrowse is an important step in this direction.