[DB-SIG] need some database API design advice
mal at egenix.com
Fri Apr 13 23:17:48 CEST 2012
Peter Eisentraut wrote:
>> I'm not sure I like making an explicit
>> function call for the colnames. I.e. I think sticking with the pep249
>> description attribute is a better solution, the API already exist so
>> clone that (when possible) in your new api.
I agree with Chris Clark here... doing so saves you complexity in the
dbapi layer you intend to write on top of the low level API.
> That would require populating this structure on every call, which would
> be expensive for such a low-level API, or turning the attribute into a
> fake function, which would be evil. I think this is best left to the
> plpydbapi layer on top of it.
Using properties you can do this on the fly and only when
needed. If you're writing the API in C, you can also create the
.description tuple on demand and only when needed. You can also
cache it in case you don't want to take the small extra hit
of having to recreate it every time.
Professional Python Services directly from the Source (#1, Apr 13 2012)
>>> Python/Zope Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
2012-04-28: PythonCamp 2012, Cologne, Germany 15 days to go
::: Try our new mxODBC.Connect Python Database Interface for free ! ::::
eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
Registered at Amtsgericht Duesseldorf: HRB 46611
More information about the DB-SIG