Hi there, Found a way to solve it, and thought I'd share in case others search on this topic.
Replace the str(...) below with str(...).encode(), so that it looks like this: open('test.csv', 'wb').write(str(db(db.student).select()).encode()) Regards, Chris On Monday, 3 September 2018 22:53:11 UTC+8, Chris_I wrote: > > Hello All, > > Just started learning web2py a few days ago, and am really enjoying it! > > Working through the chapter on DAL in the Book, I noticed I got an error > when doing this: > > open('test.csv', 'wb').write(str(db(db.student).select())) > > > The message I get is: > > TypeError: a bytes-like object is required, not 'str' > > > It occurs in: > > > File "mypath/web2py/gluon/packages/dal/pydal/base.py", line 844, in > export_to_csv_file > > ofile.write('TABLE %s\r\n' % table) > > > > The select() returns 5 perfectly normal-looking rows. > > > Am I overlooking something obvious? > > > Thanks, > > > Chris > > > -- 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.