Perhaps you can help the django team figure out why the ORM doesn't work
with MSSQL? I understand that its not technically supported, but there must
be SOME people working on it.
If you're going straight to pyodbc, then this is likeyl to be a
python/pyodbc issue, and not django. So... you're not going to get the
level of help here that you might from the pyodbc user's group. We'll try,
but no guarantees.
For starters, you should read the docs on pyodbc. The way you're handling
the execute statement is very bad, and will open you to SQL injection
attacks. It might also be the reason it doesnt work.
bad:
cursor.execute("SELECT x.t_name, x.t_user, y.t_mail FROM tttaad200000 as x,
tttcmf200000 as y WHERE (x.t_name = y.t_name) AND (x.t_user = '%s')"%form)
Good:
cursor.execute("SELECT x.t_name, x.t_user, y.t_mail FROM tttaad200000 as x,
tttcmf200000 as y WHERE (x.t_name = y.t_name) AND (x.t_user = %s)", ( form,
) )
Note that we are no longer using the python % operator. %s here is specific
to db-api2, but please find out what pyodbc requires. it could be %s, could
be ?, or something else.
The 2nd parameter to "execute" must be a sequence. So if there's just one
element, make sure you use ( elem, ) or [ elem ]
In this form, the execute statement will do all the proper quoting for you.
Now, the error that you're getting is likely in the rows =
unicode(cursor.fetchall(), 'utf-8') line
cursor.fetcall() returns a list of tuples. you cant unicode convert all
that at once. you have to do it on the individual elements.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/5MLJDMNrYuYJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.