前面的项目实践可以看源代码,在第四天的项目中,按照老师的代码调试test_db.py时遇到如下问题:
一 image 字段问题:doesn't have a default value
解决办法:
1、打开my.ini,查找
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
修改为
sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
然后重启MYSQL
2、MySQL 5 uses a strict mode which needs to be disabled.
In Windows, Goto Start-->Programs-->MySQL->MySQL Instance Config Wizard. Follow through the Reconfigure Instance option-->Detailed Configuration-->Continue Next a few screens. At the bottom under Enable TCP/IP option there is 'Enable Strict Mode'. Deslect this option (no tick). Save changes and MySQL will restart.
3、看看你的数据库定义的时候是不是把主键生成方式设置为int的,但是没有设置为自增的!!或者数据定义的时候设置一个 默认值就可以了。
注意: 重启MySQL 方法(第二种方法无效,待自己测试)
1、MYSQL服务
我的电脑——(右键)管理——服务与应用程序——服务——MYSQL——开启(停止、重启动)
2、命令行方式
Windows
1.点击“开始”->“运行”(快捷键Win+R)。
2.启动:输入 net stop mysql
3.停止:输入 net start mysql
提示* Redhat Linux 也支持service command,启动:# service mysqld start 停止:# service mysqld stop 重启:# service mysqld restart
* Windows下不能直接重启(restart),只能先停止,再启动。
二 create缩进报错:
原因可能是复制老师的代码是出现了格式的错误,我重新复制了上面的user类的create_at,就可以了。
从网页上拷贝是,代码的缩进问媒体要注意。
三 附运行成功的截图一张
明天继续努力,加油!