> I think there's something a little simpler we need - some
> documentation. For all the SA types we should document the type that
> convert_result_value returns, and that convert_bind_param expects, and
> check that all the DBAPIs stick to this (probably with unit tests). I'm
> pretty sure there's some inconsistency at the minute.

Hi Paul,

As long as you're working with only one database, everything is fine. The SA
Dialect specifies the type conversion, and
handles any discrepancies between what the DBAPI gives, and what the SA
published type is via the convert_bind_param() and convert_result_value().

The issue comes up when working with multiple databases. I first noticed the
problem when I was surprised to see all strings coming back from SQLite as
unicode(), and not str(). I had to convert the SQLite output to MSSQL input
when working with the two databases. I would have expected SA as a database
abstraction layer to
handle stuff like this. But it for the most part, the various Dialects
just return what the DBAPI gives back.


And the various DBAPI's each have their own idea of what the "proper" Python
type is for the various SQL types. We've seen this before in various
flavors: String vs. Unicode, float vs. Decimal, String vs. date (esp.
thinking of SQLite here), and etc. If you want to shard data across say,
SQLite and Postgresql, it would be nice not to have to worry about the data
source being the determinant of the type of data coming back. Likewise for a
data migration from one to the other. If you were to migrate from SQLite to
MSSQL, you'd end with unicode data in text columns unless you took specific
steps to convert it.

Whether the type mapping are determined by convention and unit tests as you
suggest, or by an adaption layer as I imagine is of course up for grabs.
Certainly the convention method has interia on its side.  But is it really
the best way?

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to