turbodbc icon indicating copy to clipboard operation
turbodbc copied to clipboard

MySQL JSON column unsupported

Open chriskingsborough opened this issue 7 years ago • 3 comments

Using: MySQL: 5.7 (also tried MemSQL 5.8) turbodbc: 2.7.0 Python: 3.5.2

Table definition:

Column     | Type
-----------+---------
data       | json

I'm able to write json data to the table using the execute method:

    cursor = conn.cursor()
    cursor.execute("INSERT INTO ExampleTable VALUES (?)", ['{"A": 1}'])

I then try to read the data I just wrote (after committing transaction and creating new cursor) : cursor.execute("SELECT data FROM ExampleTable;")

And receive the following error: RuntimeError: Error! Unsupported type identifier for column data @ NULLABLE UNKNOWN TYPE (precision 18446744073709551612, scale 0))

chriskingsborough avatar Jul 25 '18 19:07 chriskingsborough

Hi! Thanks for the report. Could you try to cast the JSON field to VARCHAR as a workaround?

MathMagique avatar Jul 26 '18 09:07 MathMagique

Hi! This works! Thanks for the suggestion.

It would be nice to have turbodbc support the JSON datatype explicitly to avoid such workarounds.

chriskingsborough avatar Jul 26 '18 13:07 chriskingsborough

This works for me using the current master.

Using: Driver: MySQL ODBC 8.0 Unicode Driver turbodbc: 4.2.1 Python: 3.9.4

Table definition:

Column  | Type
--------+-----
data    | json (null)
>>> cursor.execute("select data from Table limit 1").fetchall()
[['{ my json data }']]

connesy avatar Sep 11 '21 10:09 connesy