question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error with JSONField and mysql-connector

See original GitHub issue

model code:

class MyModel(models.Model):
    name = models.CharField(max_length=35)
    data_json = JSONField()

makemigrations output


migrations.CreateModel(
    name='MyModel',
    fields=[
        ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
        ('name', models.CharField(max_length=35)),
        ('data_json', JSONField(default=dict)),
])

Error on running migrate


django.db.utils.ProgrammingError: BLOB, TEXT, GEOMETRY or JSON column 'data_json' can't have a default value

  • Django Version: Django 2.1.2
  • Database and version used: MySQL 5.7
  • MySQL driver: mysql-connector-python==8.0.13
  • Version: Django-MySQL==2.4.1

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
adamchainzcommented, Dec 24, 2018

Btw I have a plan to get Django to support pymysql, which I have done unofficially on a few projects and it’s worked fine (being a drop-in replacement for mysqlclient ex. MySQLdb)

0reactions
adamchainzcommented, Apr 26, 2020

Closing due to age.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Issue with long JSON field and mysql source - Airbyte
I have a field in a source mysql database that is a very long JSON string. It's formatted as a JSON datatype. When...
Read more >
Use of '.format()' vs. '%s' in cursor.execute() for mysql JSON ...
My objective is to store a JSON object into a MySQL database field of type json, using the mysql.connector library. import mysql.connector ......
Read more >
Mysql JSON Type is failed with syntax error - Liquibase Forum
When I use liquibase diff 2 mysql 8.x database to generate changelog.xml with mysql connector 8.0.15 version. The JSON type is mapped to ......
Read more >
81677: Allows to force JSON columns encoding into pure UTF-8
I tried to set the columns charset into pure utf8 but it seems we cannot do that. Could we have the choice of...
Read more >
JSON array format in MySQL not working?
ERROR 3140 (22032): Invalid JSON text: "Missing a name for object member." at position 1 in value for column 'zz_TEST_ObsJSON.jsonData'. This ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found