Michael Bayer wrote:
On May 10, 2006, at 1:32 PM, Ian Bicking wrote:
I've actually been wondering if a further division would be better.
Instead of defining objects with particular functionality, focus on
simpler protocols (aka magic methods), separately providing
implementations of that. The model that SQLAlchemy and SQLBuilder/
SQLObject use is only one of several models; for instance, I think
it's feasible to use generator comprehensions for selects, and
strings -- perhaps with some annotation -- are a natural starting
place for people who have been using the db-api directly or are
coming from other languages.
theres definitely a lot of ways to construct SQL for sure, such as
DejaVU which does them through bytecode. Also Hibernate's HQL, which
is string based, is very interesting and maybe something could be
adapted from that. In theory, people could write libraries for stuff
like this on top of the python-expression systems like those of
SQLAlchemy/SQLBuilder....having a set of objects like Select, Join,
etc. strike me as the lowest common denominator tools like these would
share at an implementation level.
I had thought about that too as I was writing that. E.g., instead of
having a magic method that produces a query string (& params), just
check for a method that returns these structured query objects. For an
actual string this is not very feasible, because it involves parsing the
SQL. But I'm also concerned that it requires the structures contain a
lot more functionality, because they have to be able to portably express
fairly high-level ideas. Off the top of my head, the difference between
a database that uses sequences and one that uses lastinsertid is pretty
substantial, in that it changes the containing logic. That's probably
not the best example, except that there do exist portability concerns
that influence more logic than might be expressable in a set of standard
declarative structures.
In the end we have to send a string and parameters to the database. So
some method or function to do that must exist. I think it's good to
defer that conversion as long as possible, which can be done if there's
a standard protocol instead of concrete types of objects being passed
around. As long as the conversion is deferred, other kinds of
introspection can be done on the query objects, even if that
introspection is optional.
--
Ian Bicking / [EMAIL PROTECTED] / http://blog.ianbicking.org
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Sqlalchemy-users mailing list
Sqlalchemy-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users