PyDAL+MSSQL+FreeTDS: pyodbc.ProgrammingError

37 views
Skip to first unread message

Wei Wang

unread,
Sep 27, 2019, 5:30:03 PM9/27/19
to web2py-users
I'm getting the error from a short pytest script:
E       pyodbc.ProgrammingError: ('42000', '[42000] [FreeTDS][SQL Server]Heterogeneous queries require the ANSI_NULLS and ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query. (7405) (SQLExecDirectW)')
                                                                                                                                                                                             /usr/local/lib/python3.6/dist-packages/pydal/adapters/base.py:412: ProgrammingError
PyDAL shows the SQL command is:
command = "SELECT NacConnectionsView.eventdate, NacConnectionsView.nacmacaddress, NacConnectionsView.nacswitch FROM NacConnectionsView WHERE (NacConnectionsView.nacmacaddress LIKE '000000%' ESCAPE '\\');"

Where did that [ESCAPE '\\'] part came from?

Thank you for any help!

--Wei Wang

villas

unread,
Oct 9, 2019, 7:30:18 AM10/9/19
to web2py-users
This is the "LIKE predicate escape character". It's harmless, but google it if you wish.


FYI please also note:

Driver / Unicode Support

PyODBC works best with Microsoft ODBC drivers, particularly in the area of Unicode support on both Python 2 and Python 3.

Using the FreeTDS ODBC drivers on Linux or OSX with PyODBC is not recommended; there have been historically many Unicode-related issues in this area, including before Microsoft offered ODBC drivers for Linux and OSX. Now that Microsoft offers drivers for all platforms, for PyODBC support these are recommended. FreeTDS remains relevant for non-ODBC drivers such as pymssql where it works very well.

Reply all
Reply to author
Forward
0 new messages