How do I specify utf8mb4 for a mySQL column in web

2019-09-05 08:24发布

问题:

In web2py, how do I make sure that a column of type='string' uses the full 4-byte unicode format (utf8mb4) when creating tables in a mySQL database?

回答1:

From the web2py side, you can specify the encoding via the set_encoding parameter in the connection string:

db = DAL('mysql://username:password@localhost/test?set_encoding=utf8mb4')