如何在 web2py 中为 mySQL 列指定 utf8mb4? [英] How do I specify utf8mb4 for a mySQL column in web2py?

查看:54
本文介绍了如何在 web2py 中为 mySQL 列指定 utf8mb4?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 web2py 中,如何确保在 mySQL 数据库中创建表时 type='string' 的列使用完整的 4 字节 unicode 格式 (utf8mb4)?

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?

推荐答案

从 web2py 端,您可以通过连接字符串中的 set_encoding 参数指定编码:

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')

这篇关于如何在 web2py 中为 mySQL 列指定 utf8mb4?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆