Re: [Chicken-users] Generic RDBMS Interface [Was: Re: Creating Windows GUI App]

2011-04-03 Thread Thomas Chust
2011/4/2 Thomas Chust ch...@web.de:
 [...]
 I'll stay in touch and I'll put any prototype code I produce
 into a publicly accessible version control repository :-)
 [...]

Hello,

my first prototype code is available at

  http://www.chust.org/fossils/dbi

This has undergone only minimal testing, the persistent records API
still only exists in my head and there is only a single backend driver
wrapping my SQLite3 egg.

However, most API specification is written, so if nothing else works,
you can always comment on the documentation and the way things are
supposed to work ;-)

Also, please be patient with me if I'm not very responsive during the
coming week — I'll be rather busy on a scientific conference.

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.

___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Generic RDBMS Interface [Was: Re: Creating Windows GUI App]

2011-04-02 Thread Thomas Chust
2011/4/2 Matt Welland estifo...@gmail.com:
 - Original message -
 2011/4/1 Jim Ursetto zbignie...@gmail.com:
 [...]
 Just use an alist.
 [...]

 Maybe less practical to enter on command lines, but probably more
 schemish, yes :-)

 How about a convinence function to convert the URI to an alist for those who
 prefer and for command line ease?
 [...]

This is Scheme, procedures don't have to have static type signature. I
may just allow all of the following three styles at the same time:

  (import (prefix dbi dbi:) uri-generic)

  (dbi:connect '(postgresql [host . example.com] [database . blubb]
[tty . log]))
  ;; OR
  (dbi:connect postgresql://example.com/blubb?tty=log)
  ;; OR
  (dbi:connect (uri-reference postgresql://example.com/blubb?tty=log))

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.

___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Generic RDBMS Interface [Was: Re: Creating Windows GUI App]

2011-04-01 Thread Thomas Chust
2011/4/1 Matt Welland estifo...@gmail.com:
 That is ironic. One of the things I was going to try to make available
 via the new egg system was my dbi egg
 (http://www.kiatoa.com/cgi-bin/fossils/opensrc/dir?ci=c7f1edfb8c6e036bname=dbi).
 However anything Thomas puts together will be much, uh, fresher and
 faster :)
 [...]

Hello Matt,

you give me too much credit for something I haven't even really begun
coding :-)

Anyway, my DBI interface is going to be rather similar to the one you
created, but the way I plan it, there will be one important
architectural difference: I want to make the selection of the backend
driver modular and dynamic so that adding a new driver never requires
any changes in the DBI egg's code and ideally using the new driver
will also not require any change in client code using the DBI egg.

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.

___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Generic RDBMS Interface [Was: Re: Creating Windows GUI App]

2011-04-01 Thread Thomas Chust
2011/4/1 YC yinso.c...@gmail.com:
 [...]
 would you be interested in considering to look at my racket bzlib/dbi
 package on racket planet as a potential idea for interface?  I was looking
 to port it over to chicken but never got around to it due to other things.
  it would be good to have schemers interested in databases to collaborate.
 [...]

Hello YC,

the bzlib/dbi PLaneT package is indeed a good source of inspiration
for coding another DBI system.

There is at least one small point that I would want to do differently,
though: In my opinion it has some value if the procedure establishing
the database connection has a fixed signature and driver specific
information is encoded in a single argument. I'm pondering about using
an URI for that purpose. This has the advantage that it's very easy
then to read this single parameter from a configuration file and keep
the code one writes entirely agnostic of any driver specifics.

What I like about the bzlib/dbi interface is that SQL syntax is
somewhat normalized with respect to query parameter placeholders and
reformatted by the specific driver. To make the interface more natural
I wonder whether it wouldn't be nice to pass the query parameters as
keyword arguments to the procedure executing the query, though. In
particular, this style of argument passing would be compatible with
optionally allowing positional arguments, too.

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.

___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Generic RDBMS Interface [Was: Re: Creating Windows GUI App]

2011-04-01 Thread matt welland
On Fri, 2011-04-01 at 14:35 +0200, Thomas Chust wrote:

 [...]
 There will be one important
 architectural difference: I want to make the selection of the backend
 driver modular and dynamic so that adding a new driver never requires
 any changes in the DBI egg's code and ideally using the new driver
 will also not require any change in client code using the DBI egg.

This sounds really good. My wish list for a dbi: ability to use two or
more different db backends simultaneously in the same code (a given?),
optional control over how rows are returned (e.g. list of lists, vectors
or records), and a simple and familiar api (I'm partial to sql-de-lite's
api).

Cheers,

Matt
-=-

 Ciao,
 Thomas
 
 



___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Generic RDBMS Interface [Was: Re: Creating Windows GUI App]

2011-04-01 Thread YC
Hi Thomas,

On Fri, Apr 1, 2011 at 5:47 AM, Thomas Chust ch...@web.de wrote:


 There is at least one small point that I would want to do differently,
 though: In my opinion it has some value if the procedure establishing
 the database connection has a fixed signature and driver specific
 information is encoded in a single argument. I'm pondering about using
 an URI for that purpose. This has the advantage that it's very easy
 then to read this single parameter from a configuration file and keep
 the code one writes entirely agnostic of any driver specifics.


URI is definitely an interesting approach.  I originally wanted to use a
connection string like ODBC, but realized that since I am using DBI to be
more than just for RDBMS (I have a memcached driver and a filepath driver)
and the key/value pairs is not fixed, so it becomes a situation where the
underlying driver will dictate the key/value pairs, so I just bypass the
need to parse the connection string (and user's need to format such string)
and let the underlying driver call the shot.


 What I like about the bzlib/dbi interface is that SQL syntax is
 somewhat normalized with respect to query parameter placeholders and
 reformatted by the specific driver. To make the interface more natural
 I wonder whether it wouldn't be nice to pass the query parameters as
 keyword arguments to the procedure executing the query, though. In
 particular, this style of argument passing would be compatible with
 optionally allowing positional arguments, too.


The reason I did not use keyword arguments for query is that in racket
keyword arguments needs to be quoted to pass through to the underlying
driver, but chicken might not have that issue. The alist approach I chose
can feel unwieldy at times for sure if written manually, but nice when the
alist is already formulated elsewhere (which occurs quite a bit in web code)
to be passed in.

Love to collaborate more if you are interested - it would be nice to
eventually have a single DBI mechanism for the major scheme implementations.


-- 
Cheers,
yc

http://yinsochen.com
___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Generic RDBMS Interface [Was: Re: Creating Windows GUI App]

2011-04-01 Thread Peter Bex
On Fri, Apr 01, 2011 at 12:29:40PM -0700, YC wrote:
 URI is definitely an interesting approach.  I originally wanted to use a
 connection string like ODBC, but realized that since I am using DBI to be
 more than just for RDBMS (I have a memcached driver and a filepath driver)
 and the key/value pairs is not fixed, so it becomes a situation where the
 underlying driver will dictate the key/value pairs, so I just bypass the
 need to parse the connection string (and user's need to format such string)
 and let the underlying driver call the shot.

I don't understand; doesn't an URI have the same problem as a connection
string?  You still need to parse the individual components from it and
pass them to the driver (possibly constructing another db-specific
connection string)

The Postgres API for example provides a way to pass slots in a null-delimited
array of pointers, which relieves the user from having to encode special
characters like quotes, spaces or colons specially.  This is also slightly
more efficient since you don't need to parse anything.

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music.
-- Donald Knuth

___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Generic RDBMS Interface [Was: Re: Creating Windows GUI App]

2011-04-01 Thread YC
On Fri, Apr 1, 2011 at 12:40 PM, Peter Bex peter@xs4all.nl wrote:

 On Fri, Apr 01, 2011 at 12:29:40PM -0700, YC wrote:
  URI is definitely an interesting approach.  I originally wanted to use a
  connection string like ODBC, but realized that since I am using DBI to be
  more than just for RDBMS (I have a memcached driver and a filepath
 driver)
  and the key/value pairs is not fixed, so it becomes a situation where the
  underlying driver will dictate the key/value pairs, so I just bypass the
  need to parse the connection string (and user's need to format such
 string)
  and let the underlying driver call the shot.

 I don't understand; doesn't an URI have the same problem as a connection
 string?  You still need to parse the individual components from it and
 pass them to the driver (possibly constructing another db-specific
 connection string)


Correct - I was just explaining my rationale on why I did not take such an
approach.

-- 
Cheers,
yc

http://yinsochen.com
___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Generic RDBMS Interface [Was: Re: Creating Windows GUI App]

2011-04-01 Thread Jim Ursetto
On Apr 1, 2011, at 7:47 AM, Thomas Chust wrote:

 There is at least one small point that I would want to do differently,
 though: In my opinion it has some value if the procedure establishing
 the database connection has a fixed signature and driver specific
 information is encoded in a single argument. I'm pondering about using
 an URI for that purpose.

Just use an alist.
Jim

___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Generic RDBMS Interface [Was: Re: Creating Windows GUI App]

2011-04-01 Thread Thomas Chust
2011/4/1 Jim Ursetto zbignie...@gmail.com:
 On Apr 1, 2011, at 7:47 AM, Thomas Chust wrote:

 There is at least one small point that I would want to do differently,
 though: In my opinion it has some value if the procedure establishing
 the database connection has a fixed signature and driver specific
 information is encoded in a single argument. I'm pondering about using
 an URI for that purpose.

 Just use an alist.
 [...]

Maybe less practical to enter on command lines, but probably more
schemish, yes :-)


-- 
When C++ is your hammer, every problem looks like your thumb.

___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Generic RDBMS Interface [Was: Re: Creating Windows GUI App]

2011-04-01 Thread Thomas Chust
2011/4/1 YC yinso.c...@gmail.com:
 [...]
 The reason I did not use keyword arguments for query is that in
 racket keyword arguments needs to be quoted to pass through to the
 underlying driver, but chicken might not have that issue.

Hello YC,

this is not really true: While Racket doesn't pass keyword arguments
the same way as positional arguments for reasons of efficiency, it is
still possible to programmatically create procedures that accept
arbitrary sets of keyword arguments and process them somehow. Check
out the documentation of make-keyword-procedure [1] in the Racket
reference if you want to look into this.

CHICKEN however does pass keyword arguments just like positional
arguments.

 The alist approach I chose can feel unwieldy at times for sure if
 written manually, but nice when the alist is already formulated
 elsewhere (which occurs quite a bit in web code) to be passed in.

That's a good point to keep in mind.

 Love to collaborate more if you are interested - it would be nice to
 eventually have a single DBI mechanism for the major scheme
 implementations.
 [...]

Sure, I'll stay in touch and I'll put any prototype code I produce
into a publicly accessible version control repository :-)


Ciao,
Thomas


[1] 
http://docs.racket-lang.org/reference/procedures.html#(def._((lib._racket/private/base..rkt)._make-keyword-procedure))


-- 
When C++ is your hammer, every problem looks like your thumb.

___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Generic RDBMS Interface [Was: Re: Creating Windows GUI App]

2011-04-01 Thread John Cowan
Thomas Chust scripsit:

  The alist approach I chose can feel unwieldy at times for sure if
  written manually, but nice when the alist is already formulated
  elsewhere (which occurs quite a bit in web code) to be passed in.
 
 That's a good point to keep in mind.

An advantage of the alist approach is that you can use quasiquote to
create it:

(foo `((bar . ,bar-value) (baz . ,baz-value) (quux . ,quux-value)))

This deals nicely with situations where some key values are fixed
at the point of call and others are variable.

-- 
Not to perambulate John Cowan co...@ccil.org
the corridors  http://www.ccil.org/~cowan
during the hours of repose
in the boots of ascension.   --Sign in Austrian ski-resort hotel

___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Generic RDBMS Interface [Was: Re: Creating Windows GUI App]

2011-04-01 Thread Matt Welland
- Original message -
 2011/4/1 Jim Ursetto zbignie...@gmail.com:
  On Apr 1, 2011, at 7:47 AM, Thomas Chust wrote:
  
   There is at least one small point that I would want to do
   differently, though: In my opinion it has some value if the
   procedure establishing the database connection has a fixed signature
   and driver specific information is encoded in a single argument. I'm
   pondering about using an URI for that purpose.
  
  Just use an alist.
  [...]
 
 Maybe less practical to enter on command lines, but probably more
 schemish, yes :-)

How about a convinence function to convert the URI to an alist for those who 
prefer and for command line ease?
 
(dbi:open (dbi:uri sqlite3:test.db))

Matt
-=-
 
 -- 
 When C++ is your hammer, every problem looks like your thumb.
 
 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 http://lists.nongnu.org/mailman/listinfo/chicken-users

___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Generic RDBMS Interface [Was: Re: Creating Windows GUI App]

2011-04-01 Thread YC
On Fri, Apr 1, 2011 at 5:17 PM, Thomas Chust ch...@web.de wrote:


 this is not really true: While Racket doesn't pass keyword arguments
 the same way as positional arguments for reasons of efficiency, it is
 still possible to programmatically create procedures that accept
 arbitrary sets of keyword arguments and process them somehow. Check
 out the documentation of make-keyword-procedure [1] in the Racket
 reference if you want to look into this.


Did not know about this - thanks for the tip.

-- 
Cheers,
yc

http://yinsochen.com
___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Generic RDBMS Interface [Was: Re: Creating Windows GUI App]

2011-03-31 Thread Thomas Chust
2011/3/31 Stephen Eilert spedr...@gmail.com:
 On Thu, Mar 31, 2011 at 1:46 PM, Thomas Chust ch...@web.de wrote:
 [...]
 However, there is currently no database-independent layer like
 Perl's DBI module that provides a uniform API for all other
 relational database drivers.

 Oh, that's been one of my pet peeves for a long time now. The closest
 we have is awful's $db procedure.
 [...]

Hello,

since I've already written a bunch of database abstraction code for my
pandora egg and other projects, I think I could create something
useful and simple relatively quickly.

I'll have a try at developing a CHICKEN DBI egg at some point within
the next few weeks.

 [...]
 I've toyed with the idea, but I am afraid I'm not knowledgeable enough
 about all RDBMS to come up with a decent API. Any suggestions?
 [...]

My plan is to create an abstraction layer that is just powerful enough
to include not only a simple SQL interface but also a simple database
- record mapping facility. At the same time the API to implement
from the database driver side should remain quite basic and simple,
too.

If the backend driver just provides the following operations that
should probably already be enough:

  * Open/close a database
  * Prepare/finalize an SQL statement
  * Execute a statement with parameters, passing any result rows to a
callback
  * Escape an identifier for use in an SQL statement
  * Generate a string suitable as a parameter placeholder in an SQL
statement

I'll keep the list posted on any progress I make with this endeavour
;-)

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.

___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Generic RDBMS Interface [Was: Re: Creating Windows GUI App]

2011-03-31 Thread Matt Welland
That is ironic. One of the things I was going to try to make available
via the new egg system was my dbi egg
(http://www.kiatoa.com/cgi-bin/fossils/opensrc/dir?ci=c7f1edfb8c6e036bname=dbi).
However anything Thomas puts together will be much, uh, fresher and
faster :)

On Thu, Mar 31, 2011 at 4:05 PM, Thomas Chust ch...@web.de wrote:
 2011/3/31 Stephen Eilert spedr...@gmail.com:
 On Thu, Mar 31, 2011 at 1:46 PM, Thomas Chust ch...@web.de wrote:
 [...]
 However, there is currently no database-independent layer like
 Perl's DBI module that provides a uniform API for all other
 relational database drivers.

 Oh, that's been one of my pet peeves for a long time now. The closest
 we have is awful's $db procedure.
 [...]

 Hello,

 since I've already written a bunch of database abstraction code for my
 pandora egg and other projects, I think I could create something
 useful and simple relatively quickly.

 I'll have a try at developing a CHICKEN DBI egg at some point within
 the next few weeks.

 [...]
 I've toyed with the idea, but I am afraid I'm not knowledgeable enough
 about all RDBMS to come up with a decent API. Any suggestions?
 [...]

 My plan is to create an abstraction layer that is just powerful enough
 to include not only a simple SQL interface but also a simple database
 - record mapping facility. At the same time the API to implement
 from the database driver side should remain quite basic and simple,
 too.

 If the backend driver just provides the following operations that
 should probably already be enough:

  * Open/close a database
  * Prepare/finalize an SQL statement
  * Execute a statement with parameters, passing any result rows to a
    callback
  * Escape an identifier for use in an SQL statement
  * Generate a string suitable as a parameter placeholder in an SQL
    statement

 I'll keep the list posted on any progress I make with this endeavour
 ;-)

 Ciao,
 Thomas


 --
 When C++ is your hammer, every problem looks like your thumb.

 ___
 Chicken-users mailing list
 Chicken-users@nongnu.org
 http://lists.nongnu.org/mailman/listinfo/chicken-users


___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users


Re: [Chicken-users] Generic RDBMS Interface [Was: Re: Creating Windows GUI App]

2011-03-31 Thread YC
On Thu, Mar 31, 2011 at 4:05 PM, Thomas Chust ch...@web.de wrote:


 Hello,

 since I've already written a bunch of database abstraction code for my
 pandora egg and other projects, I think I could create something
 useful and simple relatively quickly.

 I'll have a try at developing a CHICKEN DBI egg at some point within
 the next few weeks.


Thomas -

would you be interested in considering to look at my racket bzlib/dbi
package on racket planet as a potential idea for interface?  I was looking
to port it over to chicken but never got around to it due to other things.
 it would be good to have schemers interested in databases to collaborate.

-- 
Cheers,
yc

http://yinsochen.com
___
Chicken-users mailing list
Chicken-users@nongnu.org
http://lists.nongnu.org/mailman/listinfo/chicken-users