0

In the python shell (python 2.7, django 1.6, Windows 8), I'm trying to execute a simple query against one of my table in SQL Server 2008 (engine=django_mssql):

connection.cursor.execute("SELECT * from mymodel_mytable")

The result is None. The connection is working since a simple get :

Mymodel.objects.get(pk=1)

returns the expected row. If I do the same in another shell (Ubuntu, engine=django_pyodbc), it returns the expected pyodbc_Cursor object on which I can fetch the rows.

Where am I wrong? Please, help! Regards, Patrick

EDIT: my DATABASES dict in settings is:

DATABASES = {
'default': {
       'ENGINE': "sqlserver_ado",
       'HOST': "myhost,myport",
       'USER': "myuser",
       'PASSWORD': "mypass",
       'NAME': "myDB",
       'OPTIONS': {
           'provider': "SQLNCLI10",
           'extra_params': "DataTypeCompatibility=80;MARS Connection=True;"
           },
       'COMMAND_TIMEOUT': 7200,
    }
}
Patrick
  • 2,577
  • 6
  • 30
  • 53
  • Can you include your DATABASES section of settings (without the password, naturally.) – FlipperPA Mar 20 '15 at 18:54
  • Hi Patrick, I'm not familiar with sqlserver_ado. I've always used a combination of pyodbc (https://code.google.com/p/pyodbc/) and django-pyodbc-azure (https://github.com/michiya/django-pyodbc-azure), which seems to be the easiest and most popular. Perhaps try them? – FlipperPA Mar 25 '15 at 18:19
  • Thanks for the advice FlipperPA. Is Django 1.7 a requirement? – Patrick Mar 26 '15 at 13:58
  • I don't believe it does, I've been using it since Django 1.5. The only thing I'm not sure of is how it handles migration, since 1.7 brought migrations inside Django instead of using South. Good luck! – FlipperPA Mar 26 '15 at 20:53
  • I'll give it a try for sure. Thanks FlipperPA. – Patrick Mar 27 '15 at 02:04

0 Answers0