Thanks to visit codestin.com
Credit goes to github.com

Skip to content

dates are returned as None #520

Closed
Closed
@albertz

Description

@albertz

I have a table with a column of type date with entries like 2016-00-00 (only partially set, e.g. the year only). pymysql fails to return this.

import pymysql
conn = pymysql.connect(...)
cur = conn.cursor()
cur.execute("SELECT publish_date FROM pub")
for row in cur:
    print(row)

Will print only (None,).

I also reported this for peewee although it looks like this is a bug on pymysql side but I'm not exactly sure.

A work around is to use

cur.execute("SELECT CAST(publish_date AS char) FROM pub")

which will return the date as a string (e.g. it prints ("2016-00-00",)).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions