[DB-SIG] checking column types from cursor object in a database-independent way?
M.-A. Lemburg
mal at egenix.com
Fri May 3 09:55:57 CEST 2013
On 02.05.2013 19:55, Vernon D. Cole wrote:
> I forgot: pywin32 just dropped support for Python 2.3 so I can use
> decorators now.
>
> Michael, you have just contributed four lines of code to the next version
> of adodbapi.
I think we can use an example like the one Michael gave for the
DB-API v2 extension.
BTW: I'm not yet sure about the implications of using "api" directly
in the property definition w/r to reload(dbapi_module). It may be
safer to use sys.modules['dbapi_module'], but that's an implementation
detail.
> --
> Vernon
>
>
>
> On Thu, May 2, 2013 at 11:30 AM, Michael Bayer <mike_mp at zzzcomputing.com>wrote:
>
>>
>> On May 2, 2013, at 1:12 PM, Vernon D. Cole <vernondcole at gmail.com> wrote:
>>
>> So -- here is a prototype...
>>
>>
>>>>>> import adodbapi
>>>
>>>>>> c = adodbapi.connect("provider=Microsoft.ACE.OLEDB.12.0;data
>>>> source=../examples/test.mdb")
>>>
>>>>>> c
>>>
>>> <adodbapi.adodbapi.Connection object at 0x0000000001ECDF60>
>>>
>>>>>> c.dbapi
>>>
>>> <module 'adodbapi.apibase' from
>>>> 'C:\Python27\lib\site-packages\adodbapi\apibase.
>>>
>>> pyc'>
>>>
>>>>>> c.dbapi.NUMBER
>>>
>>> <adodbapi.apibase.DBAPITypeObject object at 0x00000000025E8358>
>>>
>>>
>> My implementation is:
>>
>>
>>> import apibase as api
>>
>> class Connection(object):
>>
>> # include connection attributes as class attributes required by api
>>> definition.
>>
>> dbapi = property(lambda cls: api)
>>
>> Warning = api.Warning
>>
>> ... (etc.)
>>>
>>
>> Is that what we want to see?
>>
>>
>> Python @property will pick up on the __doc__ of the method (which is also
>> expected to be an instance method), so that can be specified traditionally:
>>
>> class Connection(object):
>> @property
>> def dbapi(self):
>> "Return a reference to the DBAPI module for this Connection."
>> return api
>>
>>
>>
>>
>> --
>> Vernon Cole
>>
>>
>>
>> On Thu, May 2, 2013 at 8:54 AM, M.-A. Lemburg <mal at egenix.com> wrote:
>>
>>> On 02.05.2013 15:53, Michael Bayer wrote:
>>>>> Another readable candidate would be "connection.dbapi".
>>>>
>>>> +1 for connection.dbapi
>>>
>>> Sounds like we're reaching consensus :-)
>>>
>>> --
>>> Marc-Andre Lemburg
>>> eGenix.com
>>>
>>> Professional Python Services directly from the Source (#1, May 02 2013)
>>>>>> Python Projects, Consulting and Support ... http://www.egenix.com/
>>>>>> mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/
>>>>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
>>> ________________________________________________________________________
>>> 2013-04-30: Released eGenix PyRun 1.2.0 ... http://egenix.com/go44
>>>
>>> ::::: Try our 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
>>> http://www.egenix.com/company/contact/
>>>
>>
>>
>>
>
--
Marc-Andre Lemburg
eGenix.com
Professional Python Services directly from the Source (#1, May 03 2013)
>>> Python Projects, Consulting and Support ... http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ... http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
________________________________________________________________________
2013-04-30: Released eGenix PyRun 1.2.0 ... http://egenix.com/go44
::::: Try our 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
http://www.egenix.com/company/contact/
More information about the DB-SIG
mailing list