It took nearly a day. Final settlement, written down to the person who needs it
Required to be installed:
Python-odbc :? https://github.com/mkleehammer/pyodbc download after install
Install PYTHON-ODBC the assumption that the sql.h file is not found error, need to apt-get install g++.
This piece of code is written in C + +. Requires compiler
DJANGO-PYODBC:? https://pypi.python.org/pypi/django-pyodbc Download after install
unixodbc:http://www.unixodbc.org/. ODBC database source under Linux
Installation:./configure & make & make Install
or Apt-get install UnixODBC Unixodbc-dev
freetds:http://www.freetds.org/ SQL Server driver under Linux
Installation:./configure--prefix=/usr/local/freetds--with-tdsver=8.0--enable-msdblib--with-gnu-ld--enable-shared-- Enable-static
Make & make Install
Apt-get Install FreeTDS Freetds-dev TDSODBC
Configuration:
1. Configure FreeTDS
Find the following additions to freetds.conf:
[MySQLServer]
? ? ? ? host = SQL Server IP
? ? ? ? Port = 1433
? ? ? ? TDS Version = 8.0
? ? ? ? Client CharSet = UTF-8
Add the TSQL folder to the environment variables such as my actions: Vim/etc/profile plus a line path= $PATH:/usr/local/freetds/bin
and source/etc/profile it into effect immediately.
Test FreeTDS Whether the installation was successful:
Tsql-c look at the installation environment
TSQL-S mysqlserver-h SQL Server database ip-p 1433-u account-p password
Success will see information such as the following:
Locale is "en_US. UTF-8 "
Locale CharSet is "UTF-8"
Using default CharSet "UTF-8"
1>
then enter the SQL command to test it:
Use test_db
Go
SELECT * from Test;
Go
After successful installation, proceed to the next step.
2. Configure UNIXODBC
Find Odbc.ini Odbcinst.ini
Mine is in/etc/odbc.ini/etc/odbcinst.ini.
Vim/etc/odbcinst.ini Increase
[FreeTDS]
Description = ODBC of FreeTDS for Ms-sqlserver
Driver =/usr/local/freetds/lib/libtdsodbc.so
FileUsage = 1
Vim/etc/odbc.ini Increase
[ODBC connection name]
Driver = FreeTDS
ServerName = MySQLServer (FreeTDS with connection name)
Database = test_db (db name)
Test UNIXODBC Whether the security configuration is successful:
ISQL-V?ODBC Connection Name account password
Success will occur after the following information such as:
+---------------------------------------+
| connected!??????????????? |
| ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
| Sql-statement???????????? |
| Help [TableName]??????????? |
| Quit?????????????????? |
| ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? |
+---------------------------------------+
Sql>
Write a few SQL statements to test it, but this time no longer use test_db. Because the database name has already been provisioned
SELECT * FROM Test
I don't have to go, huh?
3. After installing PYTHON-ODBC and DJANGO-PYODBC, configure the Django setting (it's easier to install)
' Kids ': {
? ? ? ? ' ENGINE ': ' Django_pyodbc ',
? ? ? ? ' Name ': ' Database name ', #这个不须要. Only Django has a limit and must have a name entry. It's not going to work here, actually, in Odbc.ini.
? ? ? ? ' USER ': ' Account ',
? ? ? ? ' PASSWORD ': ' PASSWORD ',
? ? ? ? ' HOST ': ', #这个也不会生效, the actual effect is configured in freetds.conf
? ? ? ? ' OPTIONS ': {
? ? ? ? ? ? ? ? ' Driver ': ' FreeTDS ',
? ? ? ? ? ? ? ? ' DSN ': ' ODBC connection name ', #ODBC DSN name defined in your Odbc.ini,
? ? ? ? }
over!
Linux (Debian) system Django with remotely connected SQL Server database