This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: db interface (was Re: Scheme is too complicated)


"Redford, John" <John.Redford@fmr.com> writes:

> I need to disagree a little with you here.  From a "practical
> engineering viewpoint", there is no need to use Guile. I would rather
> Guile took another 2 years to establish interfaces to databases than
> that it simply rush out a clone of some other language's interface. It
> is worth considering what everyone else has done, but it is also
> important to remember that this is Scheme.. a much more powerful
> language than most of the others, and entirely novel solutions are
> possible.

I'd like to see the time taken as well.  One thing I don't want guile
to be is a bloated scheme.  A scheme with a series of frankenstein
parts from other languages popular at the time grafted onto it,
sometimes with arms sticking out of foreheads, and one leg being much
to short for the other.  I'm really not interested in re-creating the
stupidity of all the other scripting languages, but with parenthetical
sugar.

As far as connecting to a database, that's fairly straightforward and
I don't think much can be done there, except maybe provide things
like: (with-db-connect) and such to get rid of all the lame DB
connection management headaches.

For handling results you'd want some nice coercion to scheme types,
but also some easier ways to get at the data, like a destructuring
bind perhaps.  I wouldn't wanna go poking around a buch of
psuedo-objects representing "result sets" and "rows".  Building a nice
set interface to tables would rock, and then generate SQL from that.

Actually, it would seem that sql generation is a almost a must, or at
least some shortcuts should be provides so that either:

(find-if (< "age" 10) db-table)  ;generate sql from the scheme like
				 ;second argument

(find-if "age < 10" db-table)	 ; just use the string as an sql
				 ; fragment for qualifiying
				 ; it owuld make
				 ; select from table where age < 10;
				 ; or something to that effect.
			


would generate the sql for you and give you back a list of rows in
that table matching.  Same with "remove-if" and all the other set
operations.

Automatic updating would rock too, where you could do some
transformation on the set and have all the sql munging done
for you.

I hope we can get something a bit more like what I'm suggesting than
say:

(define dbconn (open-db "some-db-identifier-with-hostname"))
(define results (do-query dbconn
		          "select blah from blah where blah = blah;"))


Guile users should be spared the pain, they should just be able to do:

(with-db-table "some-db-table-identifier"
	(lambda (table)
	       (append *hit-list*
		       (db-find-if "home = \"Redmond\"" table))))