From: IF Computer Asia Ltd.
Subject: Newbie Announcement: STk intrface to MSQL API
Date: 
Message-ID: <3s3c03$lll@news.hk.net>
Newbie Announcement: STk interface to MSQL API
==============================================

I have recently spent a weekend on an interface from STk to the API 
library of Msql. It is my first time to make something
that I think is contributable to the community...Hence, 'Newbie 
Announcement'. 

STk is a nearly-R4RS compliant Scheme interpreter
written by Erick Gallesio (··@unice.fr) of University of Nice, France. 
STk has an interface to the Tk toolkit itself. It is like the Tcl
language of 'wish' replaced with Scheme. That means you can write GUI 
applications with Tk outlook using STk. The most update version as of 
today is STk-2.1.7 which can be obtained by ftp to 

		kaolin.unice.fr:/pub 

'Msql is a lightweight database engine designed to provide fast access to 
stored data with low memory requirements.', quoted from the Msql version 1.0.1
manual. It supports a subset of Ansi SQL as query language. Msql is written
by David J. Hughes (·····@Bond.edu.au) of Bond University, Australia and can
be obtained by ftp to

		Bond.edu.au:/pub/Minerva/msql

(I have no information about the newest version, sorry. The version I am using
is 1.0.5)

The interface I have written preserves all the functionalities of the API
provided by Msql. The whole API contains 15 functions all in all. And these
are now accessible as STk primitives. They are:
	
							Returned obj
							------------
	(msql-connect)					socket	
	(msql-connect hostname)				socket	
	(msql-select-db socket database-name)		integer
	(msql-query socket query)			integer
	(msql-store-result)				result-handle	
	(msql-free-result result-handle)		#[undefined]	
	(msql-fetch-row result-handle)			list-of-row	
	(msql-data-seek result-handle position)		#[undefined]
	(msql-num-rows result-handle)			integer
	(msql-fetch-field result-handle)		list-of-field
	(msql-field-seek result-handle position)	#[undefined]
	(msql-num-fields result-handle)			integer
	(msql-list-dbs socket)				result-handle
	(msql-list-tables socket)			result-handle
	(msql-list-fields socket table-name)		result-handle
	(msql-close socket)				#[undefined]

(Note: msql-connect/0 is to cater for the special case when the API function
accepts input argument as NULL)

An extra primitive provided is

	(msql-get-error)				string

Since the error generated by the Msql API should not be considered as
exception in the STk level generally, this extra primitive lets the 
programmer decide what to do with errors related to Msql.

Benefits on the STk side
========================
STk is a package rich of functionalities. Now it has one more option,
to access the functionalities of a database engine. The package now
has the functionalities of the high-level Scheme language, the Tk toolkit
and can access the functionalities of a database engine which supports
SQL, albeit a subset. :) I believe, if you fancy, you can write a GUI
like that of Microsoft-Access or something? In fact that is what I am going
to spend on the next few weekends.

Benefits on the Msql side
=========================
Msql can now be accessed using the high-level language Scheme.
One function of SQL is not supported by Msql: aggregate functions.
(sum(), avg(), count(), etc) I think you can complement this at 
the Scheme level, with the interface.

Some technical information and also question
============================================
The interface is developed on Linux (1.1.18) using gcc (g++ in fact).
You need the source file 'msql.c', modifications of the makefile and
some other files of the STk package to recompile your STk executable. 
Though I am not really sure, but I guess it would also compile without
problem on other platforms. Currently, I don't have access to other 
platforms, but later, I might.

The STk version I used is STk-2.1.6 and the Msql version is Msql 1.0.5.

My question is, there should be a way to generate a dynamic link library
which is loadable immediately by STk like

	STk> (load "msql.so")

But I am still unable to make out how to do that from the STk manual.
If anyone has any idea, could you please let me know? So that the whole
package would be more modular.

Some 'administrative' questions
===============================
Here are some administrative problems also.

First I would like to make the code GNU copylefted so that
everyone has the right to distribute/copy it in full. And everyone
is ensured to obtain everything. But how do I do that?
Do I just include a standard header stating that the sources are
copylefted? I guess I should send a mail to GNU/(FSF) for the sake
of courtesy at least?

Second, I still don't have an ftp site to place the package.
If anyone is interested in it, I could only at the moment send it
by e-mail. The files are extremely short (around 70,000 Byte all in all 
to be more indicative). Does anyone has any suggestion on a more
convenient way? 

Hope this would really be useful to the community. :)

Any other comments/questions/things to watch out, etc, I would
be grateful to hear. Please post or send mail to 

		····················@hk.net


Albert Pang
Resource Technologies Limited
Hong Kong
(····················@hk.net)