Pergunta

I'm using Ubuntu 12.04 server, Django 1.5.5, pyodbc-3.0.7 and I am trying to connect to a MSSQL 2005 server. I've installed django-pyodbc through pip and modified my settings.py like so:

 DATABASES = {
    'default': {
        'ENGINE': 'django_pyodbc', 
        'NAME': 'db_name',                     
        'USER': 'user_name',                    
        'PASSWORD': 'password',              
        'HOST': 'AB131\A_INS01',                  
        'PORT': '',                    
        'OPTIONS': {
           'host_is_server': True
        },
    }
}

But when I try to run syncdb I get:

 Error: ('IM002', '[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)')

The ODBC driver installed on the Windows machine is:

  SQL Server 6.01.7601.17514 SQLSRV32.DLL

What else do I need to do? Are there any other drivers that I need to install on either the Linux or Windows machine?

Foi útil?

Solução

You need a driver installed on the django-pyodbc application server.

Take a look at FreeTDS install instructions on the django-pyodbc project page.

Replace tsodbc package with tdsodbc in the install section. Issue 130 has been entered to correct the wiki entry.

Alternately this SO answer may help fill in the rough patches of the django-pyodbc docs.

Outras dicas

first stape $ sudo apt-get install libmdbodbc1

edit the file /etc/odbcinst.ini like this

[Microsoft Access Driver (*.mdb)]
Description = Microsoft Access Driver (*.mdb)
Driver      = /path/to/file/libmdbodbc.so
Setup       = /path/to/file/libtdsS.so
CPTimeout   = 
CPReuse     = 

And the file /etc/odbc.ini

[Microsoft Access Driver (*.mdb)]
Description         = SQL Server
Driver              = Microsoft Access Driver (*.mdb)
Trace               = No
TraceFile           = /tmp/mssodbc.log
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top