这个问题是当时想当然了 看到python BooleanField(default=False) 便认为 对应 mysql的bit

出现问题

mysql实际字段存储值为0,但 peewee orm 后的结果却是 True.

查官方文档

http://peewee.readthedocs.io/en/latest/peewee/models.html

Field types table

Field Type Sqlite Postgresql MySQL
CharField varchar varchar varchar
FixedCharField char char char
TextField text text longtext
DateTimeField datetime timestamp datetime
IntegerField integer integer integer
BooleanField integer boolean bool
FloatField real real real
DoubleField real double precision double precision
BigIntegerField integer bigint bigint
SmallIntegerField integer smallint smallint
DecimalField decimal numeric numeric
PrimaryKeyField integer serial integer
ForeignKeyField integer integer integer
DateField date date date
TimeField time time time
TimestampField integer integer integer
BlobField blob bytea blob
UUIDField text uuid varchar(40)
BareField untyped not supported not supported

Note

Don’t see the field you’re looking for in the above table? It’s easy to create custom field types and use them with your models.

peewee 默认不支持 mysql 的 bit类型

BooleanField 对应 mysql的bool,而这个 bool 在 mysql 里就是 tinyint

处理方式,把 mysql 的字段类型改为 bool

或自定义映射类

import uuid

class UUIDField(Field):
db_field = 'uuid' def db_value(self, value):
return str(value) # convert UUID to str def python_value(self, value):
return uuid.UUID(value) # convert str to UUID

解决

peewee 对 mysql 类型支持问题,并不支持bit的更多相关文章

  1. mysql对GIS空间数据的支持,包括创建空间索引

    CREATE TABLE tb_geo( id INT PRIMARY KEY AUTO_INCREMENT, NAME ) NOT NULL, pnt POINT NOT NULL, SPATIAL ...

  2. MySQL 5.6 以上版本支持三种sql_mode模式:ANSI、TRADITIONAL和STRICT_TRANS_TABLES。

    Field 'id' doesn't have a default value问题解决方法 运维的名义关注0人评论3323人阅读2018-01-23 17:37:42   MySQL 5.0 以上版本 ...

  3. Ubuntu 15.04下MySQL 5.6.25不支持中文解决办法

    Ubuntu 15.04下MySQL 5.6.25不支持中文解决办法,apt-get install 安装的,不是源码包安装的mysql. 1 修改mysql的配置文件 /etc/mysql/conf ...

  4. mysql的5.6版本支持分区吗?

    转载请注明出处:http://blog.csdn.net/dongdong9223/article/details/72291698 本文出自[我是干勾鱼的博客] 我们知道,查看mysql是否支持分区 ...

  5. 分布式事务(三)mysql对XA协议的支持

    系列目录 分布式事务(一)原理概览 分布式事务(二)JTA规范 分布式事务(三)mysql对XA协议的支持 分布式事务(四)简单样例 分布式事务(五)源码详解 分布式事务(六)总结提高 引子 从Mys ...

  6. 转换实例存储支持为EBS支持的AMI

    转换实例存储支持为EBS支持的AMI 注:不能将实例存储支持的Windows AMI 转换为 EBS 支持的 AMI.并且,你只能转换你所拥有的 AMI. 1. 从一个EBS支持的AMI启动一个Ama ...

  7. 开源基于asio的网络通信框架asio2,支持TCP,UDP,HTTP,RPC,SSL,跨平台,支持可靠UDP,支持TCP自动拆包,TCP数据报模式等

    开源基于asio的网络通信框架asio2,支持TCP,UDP,HTTP,RPC,SSL,跨平台,支持可靠UDP,支持TCP自动拆包,TCP数据报模式等 C++开发网络通信程序时用asio是个不错的选择 ...

  8. GJM :用JIRA管理你的项目(二)JIRA语言包支持及插件支持 [转载]

    感谢您的阅读.喜欢的.有用的就请大哥大嫂们高抬贵手"推荐一下"吧!你的精神支持是博主强大的写作动力以及转载收藏动力.欢迎转载! 版权声明:本文原创发表于 [请点击连接前往] ,未经 ...

  9. MVC4 5分页控件,支持Ajax AjaxOption支持

    MVC4 5分页控件,支持Ajax AjaxOption支持 /// <summary> /// MVC4 5分页控件,支持Ajax AjaxOption支持 beta 1.0 /// 用 ...

随机推荐

  1. 干货 | AI人脸识别之人脸搜索

    本文档将利用京东云AI SDK来实践人脸识别中的人脸搜索功能,主要涉及到分组创建/删除.分组列表获取.人脸创建/删除.人脸搜索,本次实操的最终效果是:创建一个人脸库,拿一张图片在人脸库中搜索出相似度最 ...

  2. Go 验证是否字符串包含中文

    发现一个验证字符串是否包含中文滴时候,一个比正则更好使滴方法,而且是golang 自带滴验证. 不需要自己写正则验证,代码如下: package main import ( "fmt&quo ...

  3. Android开发环境搭建以及模拟环境搭建

    Android开发环境 现在主流的Android开发环境有: Eclipse + ADT + SDK Android Studio + SDK IntelliJ IDEA + SDK 现在国内大部分开 ...

  4. dfs+剪枝 poj1011

    Sticks Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 113547   Accepted: 26078 问题描述 Ge ...

  5. 洛谷 P5017 摆渡车

    题目传送门 解题思路: 个人感觉DP这东西,只可意会,不可言传 AC代码: #include<iostream> #include<cstdio> #include<cs ...

  6. IDEA查看接口的所有实现类

    查看实现类 接口下右键Diagrams->Show Diagram,选中接口右键Show Implementations 或接口下按Ctrl+H: 或接口类名左边按钮:

  7. Vue插件配置和 后台交互

    Vue插件配置和 后台交互 一.全局配置静态文件(csss, js..) 1.1 全局配置css文件 创建css文件 在main.js配置css文件 // 配置全局css样式 // 方式一 impor ...

  8. 2019年icpc上海网络赛 B Light bulbs (分块、差分)

    https://nanti.jisuanke.com/t/41399 题目大意: 有n个灯,m次操作,每次修改[l,r]内的灯,(off - on ,on - off),问最后有几盏灯亮着. 换种说法 ...

  9. 吴裕雄--天生自然 pythonTensorFlow图形数据处理:循环神经网络预测正弦函数

    import numpy as np import tensorflow as tf import matplotlib.pyplot as plt # 定义RNN的参数. HIDDEN_SIZE = ...

  10. 吴裕雄--天生自然 JAVA开发学习:接口

    [可见度] interface 接口名称 [extends 其他的接口名] { // 声明变量 // 抽象方法 } import java.lang.*; //引入包 public interface ...