Good afternoon all,

I have been coming across errors while trying to work with the built-in 
appadmin to set up tables by manually inserting entries or importing CSVs 
(using MSSQL primarily). Put simply, any text with German umlauts 
(characters with the symbols above them, such as Ä, ö) would cause web2py 
to raise an error:

UnicodeDecodeError: 'ascii' codec can't decode byte ___ in position ___: 
ordinal not in range(128)

I have been searching in vain for months trying to find a solution as most 
queries lead to issues from 2015 with pg8000, etc.

My (dirty but) simple fix:

When you are encountering the DAL hanging up with umlauts, it is most 
likely caused by the pyodbc package. Even if you remove your own pyodbc 
package, web2py still has it’s internal version to go off of.

 

To disable it:


Remove pyodbc from your local environment that web2py is running in.

Remove pypyodbc.py from web2py/gluon/contrib/pypyodbc.py

 

When the pyDAL loads up, it will not complain, as per line 63 from 
web2py/gluon/packages/dal/pydal/drivers.py:

 

 

try:

    import pyodbc

    DRIVERS['pyodbc'] = pyodbc

    #DRIVERS.append('DB2(pyodbc)')

    #DRIVERS.append('Teradata(pyodbc)')

    #DRIVERS.append('Ingres(pyodbc)')

except ImportError:

    try:

        import pypyodbc as pyodbc

        DRIVERS['pyodbc'] = pyodbc

    except ImportError:

        pyodbc = None

 
(If the driver is not found, it will just label pyodbc as none)

I hope this saves someone else the trouble in the future.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to