作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在看oursql的文档遇到了这个description for establishing a connection :
By default, oursql will try to use unicode wherever possible, and set the connection charset to utf8.
我的表和所有列都以 utf8 格式存储每个字符串。
这是否意味着,当我像这样连接到我的数据库时
conn = oursql.connect(host='127.0.0.1', user='habnabit', passwd='foobar',
db='example', port=3307)
我可以将 unicode 字符串传递给游标,然后游标会自动将它们转换为 utf8 吗?反之,游标将从数据库中以 unicode 形式返回任何字符串?所以我不必费心解码或编码?
我现在必须确定这一点。 :-)
最佳答案
你应该可以,是的。我猜你只需要 set the MySQL character set connection variables . SET NAMES
通常就足够了。
关于python - 如何在 python 中使用 OurSQL 仅在 UNICODE 中与 MySQL 数据库通信?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6445508/
我是一名优秀的程序员,十分优秀!