[python-win32] [adodbapi]cannot query date type? any example please?

机械唯物主义 : linjunhalida linjunhalida at gmail.com
Mon Mar 14 01:19:08 CET 2011


hello, is there any example for adodbapi? (more then testcase ship
with installer)
need to filter query result by time, but got error:

>>> adodbapi.version
'adodbapi v2.4.0'

Background.mdb has this table t:
create table t (data string, t date);

here is the code:

import adodbapi, win32com
import adodbapi.ado_consts as adc
import datetime, time

def main():
    filename = u"c:/workspace/Background.mdb"
    connect_string = u'DRIVER={Microsoft Access Driver
(*.mdb)};DBQ=%s;' % filename

    conn = adodbapi.connect(connect_string)
    cursor = conn.cursor()

    v = datetime.datetime(2010, 12, 27, 11, 40, 1)

    s = u'select t from t '
    cursor.execute(s)

    out = cursor.fetchall()
    for row in out: print row

    s = u'select t from t where t between ? and ?'
    cursor.execute(s, (v, v))

    out = cursor.fetchall()
    for row in out: print row


if __name__=="__main__":
    main()

here is the error:

adodbapi.adodbapi.DataError: Converting Parameter p0: adDBTimeStamp,
None <- datetime.datetime(2010, 12, 27, 11, 40, 1)


thanks for your help!


More information about the python-win32 mailing list