0
Ok, I have made all this modules chain work:
MSSQL <-> FreeTDS <-> unixODBC <-> pyodbc <-> django-pyodbc
I just have added ‘unicode_results’:True in DATABASES options in django settings:
DATABASES = {
'default': {
'ENGINE': 'sql_server.pyodbc', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'name', # Or path to database file if using sqlite3.
'USER': 'user', # Not used with sqlite3.
'PASSWORD': 'pwd', # Not used with sqlite3.
'HOST': 'server-name', # Set to empty string for localhost. Not used with sqlite3.
'PORT': 'port', # Set to empty string for default. Not used with sqlite3.
'OPTIONS': {
'unicode_results':True,
'driver': 'FreeTDS',
'host_is_server': True,
'extra_params': 'TDS_VERSION=8.0'
}
But pyodbc and isql still doesn’t work correctly – maybe I have missed other unicode-specific parameters. Going to check how odbc and pyodbc use this unicode_results parameter later. Anyway site now able to show Cyrillic symbols.
1
You get a ? returned for non-printable characters
Run the command below to see what unicode your Python setup supports :-
python -c "import sys;print(sys.maxunicode<66000)and'UCS2'or'UCS4'"
Next will need to set FreeTDS to use the same character set as Python. If FreeTDS does not support the unicode format you are using in Python you will need to change both Python and FreeTDS.
To rebuild Python from source with UCS2 enabled you need to do something like :-
$ ./configure --enable-unicode=ucs2
$ make
$ sudo make install
- [Django]-Tastypie-nonrel, django, mongodb: too many nestings
- [Django]-Getting task_ids for all tasks created with celery chord
- [Django]-Django Postgresql syncdb error
- [Django]-ImportError: No module named south
- [Django]-Django List deserialization in rest-framework
0
I was fighting with problem with cyrillic letters over week. I find diffrent solution, I just use microsoft mssql drivers for Linux, here is great how to install it on other than supported distributions (Suse, redhat): https://groups.google.com/forum/#!topic/shiny-discuss/AyFthz3UGwg
This driver returns normal utf-8, and everything working out of package.
- [Django]-Implement get_serializer in generic list view (generics.ListCreateAPIView) in Django REST Framework
- [Django]-Django Postgresql syncdb error
- [Django]-I have multiple django tables and want to query the tables in parallel