[DB-SIG] any 2.0-compliant packages for postgresql?
Nathan Clegg
nathan@geerbox.net
Wed, 27 Jun 2001 07:25:49 -0700
> Q: psycopg correctly put strings obtained by the Date and Time
> constructors inside quotes ('') as requested by the api. it should do
> the same (and maybe escape) normal strings? if that's the case don't we
> need a String constructor? how is the module supposed to know when a
> string is real string and need quoting and when i am passing it just as
> convenience but it really is a number? example...
This is the part I have issue with. The api spec does require that normal
strings be escaped and quoted. In regards to passing numbers as strings for
convenience, I would suggest doing away with it. If you mean it to be a
number, send a number, and furthermore specify %(name)d instead of %(name)s.
I appreciate conveniences, but I think this introduces the kind of ambiguity
that python's specification set out to squash in the first place.
Furthermore, all of the databases I have personally used have no problem
casting strings to numbers where required. That is, if you pass postgresql
(or oracle, or mysql...) a quoted string '768' to compare against a number
field, it with cast it to a number for you and get you the desired result.
The module doesn't really need to implement this convenience casting because
the database engine already does.