Hi,

I can't seem to export the db using db.import_from_csv_file in python3. It 
is working in python 2.

It seems to be a problem with one of the image or blob field in a table ? 
Actually there is only on blob field populated with a b64 image file, but 
yet no image file in upload field.

db.define_table('photo_id',
    Field('imagefile', 'upload'),
    Field('b64img','blob'),
    Field('id_auth_user', 'reference auth_user', writable = False, readable 
= False),
    auth.signature)

Billet d'erreur for "ECapp19" Identifiant du Billet 

127.0.0.1.2019-10-13.18-48-04.b589bcc3-5676-49ce-a64e-a9b005d108b1
<class 'TypeError'> a bytes-like object is required, not 'str' Version 
web2py™ Version 2.18.5-stable+timestamp.2019.04.08.04.22.03 
Python Python 3.6.8: /usr/bin/python3 (prefix: /usr) Traceback 

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.

Traceback (most recent call last):
  File "/home/www-data/web2py/gluon/restricted.py", line 219, in restricted
    exec(ccode, environment)
  File "/home/www-data/web2py/applications/ECapp19/controllers/manage.py" 
<https://localhost/admin/default/edit/ECapp19/controllers/manage.py>, line 135, 
in <module>
  File "/home/www-data/web2py/gluon/globals.py", line 421, in <lambda>
    self._caller = lambda f: f()
  File "/home/www-data/web2py/applications/ECapp19/controllers/manage.py" 
<https://localhost/admin/default/edit/ECapp19/controllers/manage.py>, line 47, 
in save_db
    db.export_to_csv_file(dumpfile)
  File "/home/www-data/web2py/gluon/packages/dal/pydal/base.py", line 852, in 
export_to_csv_file
    ofile, *args, **kwargs)
  File "/home/www-data/web2py/gluon/packages/dal/pydal/objects.py", line 2811, 
in export_to_csv_file
    value = base64.b64encode(value)
  File "/usr/lib/python3.6/base64.py", line 58, in b64encode
    encoded = binascii.b2a_base64(s, newline=False)
TypeError: a bytes-like object is required, not 'str'

Error snapshot [image: help] 
<https://localhost/admin/default/ticket/ECapp19/127.0.0.1.2019-10-13.18-48-04.b589bcc3-5676-49ce-a64e-a9b005d108b1#>
 

TypeError(a bytes-like object is required, not 'str') 

inspect attributes 
Frames 
   
   - 
   
   *File /home/www-data/web2py/gluon/restricted.py in restricted at line 
   219* code arguments variables 
   - 
   
   *File /home/www-data/web2py/applications/ECapp19/controllers/manage.py 
   in <module> at line 135* code arguments variables 
   - 
   
   *File /home/www-data/web2py/gluon/globals.py in <lambda> at line 421* 
   code arguments variables 
   - 
   
   *File /home/www-data/web2py/applications/ECapp19/controllers/manage.py 
   in save_db at line 47* code arguments variables 
   - 
   
   *File /home/www-data/web2py/gluon/packages/dal/pydal/base.py in 
   export_to_csv_file at line 852* code arguments variables 
   - 
   
   *File /home/www-data/web2py/gluon/packages/dal/pydal/objects.py in 
   export_to_csv_file at line 2811* code arguments variables 
   - 
   
   *File /usr/lib/python3.6/base64.py in b64encode at line 58* code 
   arguments variables 
   Function argument list 
   
   
(s='data:image/jpeg;base64,/9j/4AAQSkZJRgABAgEBLAEsA...xIWdmOeSSeTn/AOvSJnOM8j9KcWyMjgU5DgHuakVjjgV//9k=',
 
   altchars=None)
   Code listing 
   
   53.
   54.
   55.
   56.
   57.
   58.
   59.
   60.
   61.
   62.
   
   
       Optional altchars should be a byte string of length 2 which specifies an
       alternative alphabet for the '+' and '/' characters.  This allows an
       application to e.g. generate url or filesystem safe Base64 strings.
       """
       encoded = binascii.b2a_base64(s, newline=False)
       if altchars is not None:
           assert len(altchars) == 2, repr(altchars)
           return encoded.translate(bytes.maketrans(b'+/', altchars))
       return encoded
   
   Variables 
   encoded undefined 
   global binascii <module 'binascii' (built-in)> 
   binascii.b2a_base64 <built-in function b2a_base64> 
   s 
   
'data:image/jpeg;base64,/9j/4AAQSkZJRgABAgEBLAEsA...xIWdmOeSSeTn/AOvSJnOM8j9KcWyMjgU5DgHuakVjjgV//9k='
 
   newline undefined
   
   
Any ideas?

Mamisoa

   
   

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/8e0d9043-2282-4474-95df-498192348c68%40googlegroups.com.

Reply via email to