django sqlite3上的数据类型不匹配错误 [英] Data type mismatch error on django sqlite3

查看:242
本文介绍了django sqlite3上的数据类型不匹配错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这些是我的桌子



music_name = char(用户名),userId(int)



意思是= char(含义),userid(int)



我希望将结果存储在第三个表= music_result(用户名,含义)



i使用了加入合并这个





当我试图这样做时我得到了像
这样的错误


sqlite3.IntegrityError:数据类型不匹配



请做帮我解决这个错误



我尝试过:



Hi these are my tables

music_name = char(username),userId(int)

meaning = char(meaning),userid(int)

and i want to store the result on third table=music_result(username,meaning)

i have used the join to merge this


when i tried to do this i got an error like

sqlite3.IntegrityError: datatype mismatch

please do help me to solve this error

What I have tried:

db = sqlite3.connect('db.sqlite3')

cursor = db.cursor()


cursor.execute('\n'

                       'INSERT INTO  music_result SELECT username, meaning ,NULL\n'

                       'FROM music_name N JOIN music_sample1 T ON N.userid = T.userid \n')
        db.commit() 

推荐答案

啊现在很清楚:

ahhh now it is clear:
class result(models.Model):
userid = models.IntegerField(primary_key=True)



a PrimaryKey字段不能为NULL。

可以将其设置为Identity字段。生成ID的数字不会生成,INSERT查询中不需要。


a PrimaryKey field cannot be NULL.
Can you set it up as Identity field. A number for ID is than generated and is not needed in the INSERT query.


这篇关于django sqlite3上的数据类型不匹配错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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