I have a peewee model like so:
class User(peewee.Model):
name = peewee.CharField(unique=True)
some_json_data = peewee.CharField()
requested_at = peewee.DateTimeField(default=datetime.now())
I know that peewee doesn't support a JSONField for a MySQL DB, but anyway, I though if I could just convert it to a string format and save to db, I can retrieve it as is.
Let's say, for example, this is my JSONField that I am writing to the DB:
[
{
'name': 'abcdef',
'address': 'abcdef',
'lat': 43176757,
'lng': 42225601
}
]
When I fetch this (JSONField) data, the output is like so:
u'[{u\'name\': u\'abcdef\', u\'address\': u\'abcdef\', u\'lat\': 43176757, u\'lng\': 42225601\'}]'
Trying a simplejson load of this is giving me an error like so:
JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 3 (char 2)
I've tried json dumps of the json data before entering it to the DB and seeing if something would work, but still I have no luck with that.
I am looking for a solution that involves peewee's custom field options and I want to stick my MySQL. Can someone guide me?
JSONField
fromplayhouse.mysql_ext
– Floris