Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sudo pip install --upgrade pip
- sudo pip install django-pyodbc
- sudo pip install django-sqlserver
- sudo pip install django-mssql
- sudo pip install django-pyodbc-azure
- brew install freetds
- brew install freetds --with-unixodbc
- ~/.bash_profile
- #ODBC
- export ODBCSYSINI=/usr/local/opt/unixodbc/etc
- export ODBCINI=/usr/local/opt/unixodbc/etc/odbc.ini
- /etc/odbcinst.ini
- [FreeTDS]
- Driver=/usr/local/lib/libtdsodbc.so
- Setup=/usr/local/lib/libtdsodbc.so
- Server={host}
- UsageCount=1
- Port=1433
- Database={db name}
- User={user name}
- Password={password}
- TDS_Version=7.2
- client_charset=utf-8
- /etc/odbc.ini
- [FreeTDS]
- Driver = FreeTDS
- ServerName = {hostname}
- Database = {db name}
- UserName = {user name}
- Password = {password}
- Port = 1433
- Protocol = 7.2
- TDS_Version = 8.0
- tsql -S FreeTDS -p 1433 -U {user name} -P {password}
- It’s ok to connect to ‘INFORMATION_SCHEMA’ DB。
- But when I try:
- tsql -S FreeTDS -p 1433 -U {user name} -P {password} -D {database name}
- I had problems:
- Msg 4075 (severity 16, state 1) from {hostname} Line 1:
- "The USE database statement failed because the database collation Chinese_Traditional_Stroke_Order_100_CS_AS_WS is not recognized by older client drivers. Try upgrading the client operating system or applying a service update to the database client software, or use a different collation. See SQL Server Books Online for more information on changing collations."
- Msg 18456 (severity 14, state 1) from {hostname} Line 1:
- "Login failed for user ‘{user name}’.”
- Error 20002 (severity 9):
- Adaptive Server connection failed
- There was a problem connecting to the server
- If I try “tsql -S FreeTDS -p 1433 -U {user name} -P {password}” and under,
- 1> USE somedb
- 2> go
- Msg 40508 (severity 16, state 1) from {hostname} Line 1:
- "USE statement is not supported to switch between databases. Use a new connection to connect to a different database."
- problems again. (I fund some pages to says: USE is not work at a MSSQL DB on Azure)
- django.db.utils.Error: ('08001', '[08001] [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)')
- settings.py
- DATABASES = {
- 'default': {
- 'ENGINE': 'sql_server.pyodbc',
- 'NAME': ‘{database name}’,
- 'USER': ‘{user name}’,
- 'PASSWORD': ‘{password}’,
- 'HOST': ‘{hostname}’,
- 'PORT': '1433',
- 'OPTIONS': {
- 'driver': 'FreeTDS',
- },
- }
- }
- and
- $python manage.py shell
- >>> from app.models import {ModelName}
- >>> {ModelName}.objects.all()
- Error: ('08001', '[08001] [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)')
- (again, no surprise.)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement