Can I use MySQL on Django(dev 1.6.x) with Python3.x?

后端 未结 4 577
不思量自难忘°
不思量自难忘° 2020-12-04 16:36

I use Django dev(1.6.x) from git repo and I want to use MySQL , But on the settings.py file can not setup MySQL because MySQL is not supported in python3 and Dj

4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-04 17:17

    I've been waiting for mysql support with django and python 3.x for ages and finally there is a somewhat official compatible engine that let's you do this.

    http://dev.mysql.com/doc/connector-python/en/connector-python-django-backend.html

    I created a virtualenv using python 3 and was able to use the database specific settings in the above link.

    DATABASES = {
        'default': {
            'NAME': 'mydatabase',
            'ENGINE': 'mysql.connector.django',
            'USER': 'mydbuser',
            'PASSWORD': 'mydbpassword',
            'OPTIONS': {
              'autocommit': True,
            },
        }
    }
    

    Cut and pasted the models from the Django Poll Tutorial and 'python manage syncdb' worked.

    More testing to see if the entire ORM supports this connector.

    My full write up here: http://bunwich.blogspot.ca/2014/02/finally-mysql-connector-that-works-with.html

提交回复
热议问题