Connect to MSSQL from Django on CentOS
Steps:
- run the below commands in the terminal (it will install needed packages).
- yum install python python-devel libxml2 libxml2-devel python-setuptools zlib-devel wget openssl-devel pcre pcre-devel sudo gcc make autoconf automake
- yum install unixODBC*
- yum install freetds*
- add the below 3 lines to /etc/odbcinst.ini (without the numbers and the dot after it)
- [FreeTDS]
- Description = FreeTDS
- Driver = /usr/lib64/libtdsodbc.so
- add the below to /etc/odbc.ini (without the numbers and the dot after it)
- [TS]
- Description = "test"
- Driver = FreeTDS
- Server = 17.1.10.10
- Port = 1433
- Database = mydatabase
- in the terminal run the below command
- isql TS yourusename yourpassword
- if you see "SQL>" then out setup is correct
- in your Django project in setting.py the database setting in DATABASES section
DATABASES = {
'default': {
'ENGINE': 'sql_server.pyodbc'
'NAME': 'mydatabasename',
'USER': 'yourusername', # Not used with sqlite3.
'PASSWORD': 'yourpassword', # Not used with sqlite3.
'HOST': '17.1.10.10', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '1433',
'OPTIONS':{ 'host_is_server': True, }
},
}
Have fun :)
Prerequisites:.
- Django 1.4 installed
- go to django website and download the package
- cd to the directory and type python setup.py install
- python 2.6 installed
- pyodbc installed https://code.google.com/p/pyodbc/downloads/list
- download the .zip file and extract it.
- cd to the directory and type python setup.py install
- django-pyodbc installed https://github.com/avidal/django-pyodbc
- download the package and extract it
- cd to the directory and type python setup.py install
resources:
http://askubuntu.com/questions/167491/connecting-ms-sql-using-freetds-and-unixodbc-isql-no-default-driver-specified
https://library.linode.com/web-servers/nginx/python-uwsgi/fedora-14?format=print
-sorry if i forgot to mention any :)
Comments
Post a Comment