我正在尝试将范围为0-220的int值存储到TINYINT MySQL列中。
hr_max = 220
self.cur.execute("INSERT INTO variables(member, hr_max) VALUES(%s,%s)",
(member, hr_max))
self.con.commit()
但每次我写的东西都超过127.我得到:
DataError(1264,“第1行”hr_max'栏的超出范围值)
我尝试用numpy将数字解析为uint8但是如果我得到变量bytes count:
sys.getsizeof(hr_max)
我得到14
我已经尝试过作为char但它抱怨它的字符串并且预期是int。
答案 0 :(得分:0)
MySQL TINYINT的范围为:
Type Storage Minimum Value Maximum Value (Bytes) (Signed/Unsigned) (Signed/Unsigned) TINYINT 1 -128 127 0 255
因此,对于签名的TINYINT,任何大于127的东西都会导致问题。