#76 unformatted date returns none

MySQLdb-0.9.3
closed
Andy Dustman
MySQLdb (285)
5
2014-08-18
2004-02-13
calvin tolman
No

simple(unformatted) select of dates returns NoneType
for MySQL-python-0.9.3b1 and python 2.3 on Mac OS X
10.3 This problem originally occured when I upgraded
to Mac OS X 10.3 and python 2.3. (default OS X 10.3
python install)

Mysql version 4.013-standard

I attempted to use the 0.9.3.b3 version but it gives:
gunzip: MySQL-python-0.9.3b3.tar.gz: invalid compressed
data--crc error
here is a sample of code testing the values returned
when selecting now().

db = MySQLdb.connect(db=sqldb, user=sqluser,
host=sqlhost)
mysqlc = db.cursor()

get datetime

... qrystmt = 'select upper(now() + 0)'
mysqlc.execute(qrystmt)
1L
print mysqlc._rows
(('20040212153953',),)

qrystmt = 'select now()'
mysqlc.execute(qrystmt)
1L
print mysqlc._rows
((None,),)
type(mysqlc._rows[0][0])
<type 'NoneType'="">

Discussion

  • Andy Dustman
    Andy Dustman
    2004-02-29

    Logged In: YES
    user_id=71372

    don't play with _rows

     
  • calvin tolman
    calvin tolman
    2004-02-29

    Logged In: YES
    user_id=974317

    fetchall seems to have the same problem. Should I use
    something else?

    db = MySQLdb.connect(db=sqldb, user=sqluser, host=sqlhost)
    mysqlc = db.cursor()

    get datetime

    ... qrystmt = 'select upper(now() + 0)'
    mysqlc.execute(qrystmt)
    1L
    print mysqlc.fetchall()
    (('20040228232259',),)
    qrystmt = 'select now()'
    mysqlc.execute(qrystmt)
    1L
    print mysqlc.fetchall()
    ((None,),)
    print mysqlc.fetchone()
    None

     
  • Andy Dustman
    Andy Dustman
    2004-05-18

    Logged In: YES
    user_id=71372

    c=db.cursor()
    c.execute('select upper(now() + 0)')
    1L
    c.fetchall()
    (('20040518005441',),)
    c.execute('select upper(now())')
    1L
    c.fetchall()
    (('2004-05-18 00:54:54',),)
    c.execute('select now()')
    1L
    c.fetchall()
    ((datetime.datetime(2004, 5, 18, 0, 55, 11),),)