[DB-SIG] Controlling return types for DB APIs
Michael Bayer
mike_mp at zzzcomputing.com
Wed Apr 18 02:50:32 CEST 2007
On Apr 17, 2007, at 4:12 PM, Federico Di Gregorio wrote:
>
> The Python->SQL part is perfect for adaptation and, for example,
> psycopg
> has a micro-protocols implementation to help with the adaptation of
> any
> Python object into a valid ISQLQuote one. Why two different systems?
> Because transating Python to SQL and SQL to Python are two very
> different operations, IMHO.
they are different operations, but their semantics are mirror images
of one another. it follows very closely if you are binding a
datetime object to a bind param which is in a SQL expression being
compared against a particular column, that the rules which convert
the datetime to a SQL value are the same rules in reverse that would
convert the selection of that column in the result. this is why i
think the "type" of a column, both its bind param adaptation as well
as its result row adaptation, can be expressed by the same rule
object in most cases. and I know it works since this is how
sqlalchemy has been doing it for quite a while now.
More information about the DB-SIG
mailing list