[python-sybase] NumericType not hashable?
Harri Pasanen
harri.pasanen at trema.com
Wed, 24 Apr 2002 16:35:38 +0200 (CEST)
Hi,
By the looks of it, NumericType is not python hash table friendly.
That means that something like:
c.execute('select id, limit_id, name from Sublimit_cvt')
rows = c.fetchall()
for row in rows:
id, limit_id, name = row
c.execute('select id from MyTable')
rows = c.fetchall()
for row in rows:
id = row[0]
print map[id]
will fail if id is of type AutomaticID in Sybase.
I'm not sure if this is required by DB API, but I think it violates the
principle of least surprise.
My workaround was to force a conversion to string, so my code now reads
map[str(id)]. But maybe NumericType should be modified to act as any number
when used as a hash key? Any opinions?
-Harri