Re: [Chicken-users] Generic RDBMS Interface
> 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. Yay! That's the spirit! cheers, felix ___ 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/4/1 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=c7f1edfb8c6e036b&name=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/4/1 YC : > [...] > 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]
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]
Hi Thomas, On Fri, Apr 1, 2011 at 5: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. 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]
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]
On Fri, Apr 1, 2011 at 12:40 PM, Peter Bex 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]
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/4/1 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. > [...] 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/4/1 YC : > [...] > 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]
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 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]
- Original message - > 2011/4/1 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. > > [...] > > 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]
On Fri, Apr 1, 2011 at 5:17 PM, Thomas Chust 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