The initial program
The initial program is created for you when first start the system. Change the login details to
access your database. You will also want to change the value of YourMainTable to the name of your main table.
# Change the login details to access your MySQL database
LOGIN username password db_name localhost
# Give your system a title
SET title 'NameForYourSystem'
# Restrict it to view certain tables
SET tables_matching ALL
# Customise which fields are shown, searched or hidden etc
TABLE ALL SEARCH '%name'
MAIN_COL '%name'
# Make one table your main starting point
TABLE YourMainTable START MAIN_COL '%name'
|
The spider database program
The following program is for a scooter database.
It accesses a very simple database and contains references to pictures and external URLs.
LOGIN username password db_name localhost
# alter the look of the screens
SET tables 'scooter%'
SET title 'Scooter Database'
SET info "Feel free to correct data or add new scooters"
SET col_tab_bg lightgrey
# applies to all tables
TABLE ALL MAIN_COL '%name'
EDIT GUEST
URL link, '%img%'
# applying to specific tables
TABLE scooter_links MAIN_COL comment
TABLE scooters VERTICAL
START PICK
SEARCH '%name'
TABLE scooter_maker RENAME "Manufacturer"
TABLE scooter_countries RENAME "Countries"
TABLE scooters RENAME "Scooters"
TABLE scooter_links RENAME "Links"
# field commands
FIELD gearing VALUES '3 speed', '4 speed' ,CVT
RENAME Gearing
DEFAULT CVT
FIELD engine_type VALUES '2 stroke','4 stroke',Electric,Hybrid
RENAME 'Engine type'
FIELD weight_kg, service_interval_km, from_year, top_speed_mph,
petrol_tank_ltr, generator_watts, price_usd, engine_cc, max_hp,
economy_mpg, seat_height_cm, wheel_size_inch FORMAT NUMBER
FIELD carb_type VALUES Carb,EFI RENAME 'Carb type'
# a few reports
REPORT "Scooter range"
"select name,from_year,
cast(( economy_mpg * petrol_tank_ltr / 4.55 ) as signed ) miles,
cast(( ((economy_mpg * petrol_tank_ltr / 4.55 ) *8 ) / 5 )
as signed ) km
from scooters
order by ( economy_mpg * petrol_tank_ltr ) desc"
REPORT "Economic scooters"
"select name,from_year, economy_mpg, service_interval_km
from scooters
order by economy_mpg desc"
|
The food database program
The following program is for the nutrition database web page.
It is longer than the other programs because it contains reports which are just simple SQL select
statements that have been given a name.
LOGIN username password db_name localhost
SET tables 'food_%'
SET title 'Food Nutrient Database'
SET info "data taken from the USDA Nutrient Data Laboratory"
TABLE food_des RENAME Foods
TABLE food_nutr_def RENAME Nutrient
TABLE food_nut_data RENAME Nutrients
TABLE food_group RENAME 'Food Groups'
TABLE food_group START
TABLE ALL SEARCH '%Desc'
MAIN_COL FdGrp_Desc, Long_Desc, NutrDesc
HIDE ComName , Shrt_Desc , ManufacName ,Ref_desc, Survey,
Num_Data_Pts, Std_Error, Deriv_Cd, Ref_NDB_No, Num_Studies,
MinVal, MaxVal, Low_EB, Up_EB, Add_Nutr_Mark, Stat_cmt, CC,
CHO_Factor
FIELD Nutr_Val RENAME Amount
FIELD NDB_No LINK food_des NDB_No
FIELD Nutr_No LINK food_nutr_def Nutr_No
REPORT 'High fibre cereals'
"select f.NDB_No, f.Long_Desc, n.Nutr_Val
from food_des f,food_nut_data n
where f.FdGrp_Cd='0800'
and n.NDB_No=f.NDB_No
and n.Nutr_No=291
order by n.Nutr_Val desc
limit 15"
REPORT 'High alcohol drinks'
"select f.NDB_No, f.Long_Desc, n.Nutr_Val
from food_des f,food_nut_data n
where f.FdGrp_Cd='1400'
and n.NDB_No=f.NDB_No
and n.Nutr_No=221
order by n.Nutr_Val desc
limit 25"
REPORT 'Foods high in this nutrient' ON Nutr_No
"select f.NDB_No, f.Long_Desc, n.Nutr_Val,d.Units
from food_des f,food_nut_data n, food_nutr_def d
where f.FdGrp_Cd='1400'
and n.NDB_No=f.NDB_No
and n.Nutr_No={ID}
and d.Nutr_No = n.Nutr_No
order by n.Nutr_Val desc
limit 25"
REPORT 'Nutrients in this food' ON NDB_No
"select d.NutrDesc,n.Nutr_No, n.Nutr_Val,d.Units
from food_des f,food_nut_data n,food_nutr_def d
where f.NDB_No = {ID}
and n.NDB_No=f.NDB_No
and d.Nutr_No = n.Nutr_No
order by d.NutrDesc
limit 500"
|
Index
|