Advertisement
Guest User

Untitled

a guest
Mar 14th, 2016
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. sudo pip install --upgrade pip
  2. sudo pip install django-pyodbc
  3. sudo pip install django-sqlserver
  4. sudo pip install django-mssql
  5. sudo pip install django-pyodbc-azure
  6. brew install freetds
  7. brew install freetds --with-unixodbc
  8.  
  9. ~/.bash_profile
  10. #ODBC
  11. export ODBCSYSINI=/usr/local/opt/unixodbc/etc
  12. export ODBCINI=/usr/local/opt/unixodbc/etc/odbc.ini
  13.  
  14. /etc/odbcinst.ini
  15. [FreeTDS]
  16. Driver=/usr/local/lib/libtdsodbc.so
  17. Setup=/usr/local/lib/libtdsodbc.so
  18. Server={host}
  19. UsageCount=1
  20. Port=1433
  21. Database={db name}
  22. User={user name}
  23. Password={password}
  24. TDS_Version=7.2
  25. client_charset=utf-8
  26.  
  27. /etc/odbc.ini
  28. [FreeTDS]
  29. Driver = FreeTDS
  30. ServerName = {hostname}
  31. Database = {db name}
  32. UserName = {user name}
  33. Password = {password}
  34. Port = 1433
  35. Protocol = 7.2
  36. TDS_Version = 8.0
  37.  
  38. tsql -S FreeTDS -p 1433 -U {user name} -P {password}
  39.  
  40. It’s ok to connect to ‘INFORMATION_SCHEMA’ DB。
  41.  
  42. But when I try:
  43.  
  44. tsql -S FreeTDS -p 1433 -U {user name} -P {password} -D {database name}
  45.  
  46. I had problems:
  47.  
  48. Msg 4075 (severity 16, state 1) from {hostname} Line 1:
  49. "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."
  50. Msg 18456 (severity 14, state 1) from {hostname} Line 1:
  51. "Login failed for user ‘{user name}’.”
  52. Error 20002 (severity 9):
  53. Adaptive Server connection failed
  54. There was a problem connecting to the server
  55.  
  56. If I try “tsql -S FreeTDS -p 1433 -U {user name} -P {password}” and under,
  57.  
  58. 1> USE somedb
  59. 2> go
  60. Msg 40508 (severity 16, state 1) from {hostname} Line 1:
  61. "USE statement is not supported to switch between databases. Use a new connection to connect to a different database."
  62.  
  63. problems again. (I fund some pages to says: USE is not work at a MSSQL DB on Azure)
  64.  
  65. django.db.utils.Error: ('08001', '[08001] [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)')
  66.  
  67. settings.py
  68. DATABASES = {
  69. 'default': {
  70. 'ENGINE': 'sql_server.pyodbc',
  71. 'NAME': ‘{database name}’,
  72. 'USER': ‘{user name}’,
  73. 'PASSWORD': ‘{password}’,
  74. 'HOST': ‘{hostname}’,
  75. 'PORT': '1433',
  76. 'OPTIONS': {
  77. 'driver': 'FreeTDS',
  78. },
  79. }
  80. }
  81.  
  82. and
  83.  
  84. $python manage.py shell
  85.  
  86. >>> from app.models import {ModelName}
  87. >>> {ModelName}.objects.all()
  88.  
  89. Error: ('08001', '[08001] [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)')
  90.  
  91. (again, no surprise.)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement