See https://github.com/web2py/pydal/wiki/Write-py2py3-compatible-code. You 
might need to report an issue on Github regarding the error below.

Anthony

On Tuesday, April 5, 2016 at 11:41:27 AM UTC-4, Thomas Sitter wrote:
>
> Looking into this further, it appears that pydal available on pypi is not 
> Python 3 compatible (i.e. use of iteritems() rather than items() on a 
> dict). Is there a Python 3 compatible version?
>
> On Tuesday, 5 April 2016 10:57:35 UTC-4, Thomas Sitter wrote:
>>
>>
>> Hello,
>>
>> I am trying to use PyDAL from a Python 3 script. I pip installed it 
>> without issue but when attempting to open up an existing database (created 
>> with web2py running on Python 2.6) I get the following error:
>>
>> form pydal import DAL
>> db = DAL('sqlite://sqlite.db', folder=db_path, auto_import=True)
>>
>> Traceback (most recent call last):
>>   File "<stdin>", line 1, in <module>
>>   File "/usr/local/lib/python3.5/site-packages/pydal/base.py", line 174, 
>> in __call__
>>     obj = super(MetaDAL, cls).__call__(*args, **kwargs)
>>   File "/usr/local/lib/python3.5/site-packages/pydal/base.py", line 496, 
>> in __init__
>>     tables=tables)
>>   File "/usr/local/lib/python3.5/site-packages/pydal/base.py", line 512, 
>> in import_table_definitions
>>     sql_fields = pickle.load(tfile)
>> TypeError: a bytes-like object is required, not 'str'
>>
>>
>> Which I can trace to these line of source code
>>
>> for filename in glob.glob(pattern):
>>     tfile = self._adapter.file_open(filename, 'r')
>>     try:
>>         sql_fields = pickle.load(tfile)
>>
>>
>> I believe tfile must be opened in 'rb' mode in Python 3. Is there a 
>> workaround so I can get this working? I have other needs that require 
>> Python 3 over Python 2.
>>
>> Thanks
>>
>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to