Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collation and charset? #96

Open
AndreaCrotti opened this issue Oct 19, 2016 · 2 comments
Open

Collation and charset? #96

AndreaCrotti opened this issue Oct 19, 2016 · 2 comments
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@AndreaCrotti
Copy link

Is there a way to define the DB url in such a way that also the COLLATION and CHARSET would get set as below?

        'mysql': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME': 'django2',
            'USER': 'user',
            'PASSWORD': 'password',
            'HOST': 'localhost',
            'PORT': '3306',
            'OPTIONS': {'init_command': 'SET storage_engine=INNODB'},
            'STORAGE_ENGINE': 'INNODB',
            'COLLATION': 'utf8-general_ci',
            'CHARSET': 'utf-8',
        },

thanks a lot!

@vdboor
Copy link

vdboor commented Dec 20, 2016

Same question here (for an external project). Looking at the source of db_url_config, it's not yet possible but it can be fixed. The STORAGE_ENGINE, COLLATION and CHARSET should be added to _DB_BASE_OPTIONS we we can write:

mysql://user:pass@localhost/django2?COLLATION=utf8-general_ci&CHARSET=utf-8

Adding &STORAGE_ENGINE=INNODB&init_comment=SET storage_engine=INNODB are likely not needed, since these are defaults since MySQL 5.5.5 and that's the minimal version Django supports.

@wolfg1969
Copy link

wolfg1969 commented Mar 2, 2017

Got 'TypeError: keywords must be strings.' when doing this.

Update:
The correct way is using lower case: '?charset=utf8'

@sergeyklay sergeyklay added documentation Improvements or additions to documentation question Further information is requested labels Sep 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants