我有一个错误 BIGINT UNSIGNED 值超出范围

I've a mistake BIGINT UNSIGNED value is out of range

我用MySql。当我使用 sql 和 python 调用相同的过程时,我得到不同的响应: 在 MySql 中它运行良好,但是当我在 python 中调用它时,我得到另一个响应

(1690, "BIGINT UNSIGNED value is out of range in '(`shop`.`t`.`lvl` - `shop`.`tree`.`lvl`)'")

程序:

    delimiter $$
CREATE procedure daily_users (us_id bigint) 
BEGIN 
    set @us_id = us_id;
     set @u_lvl = (select lvl from users where user_id = @us_id);
     set @children_first_lvl = (select count(1)
            from tree t
            join users u   
                on t.user_id = u.user_id
            join (select * from tree where user_id = @us_id) sub
                on (sub.lft < t.lft and sub.rgt > t.rgt) 
            where (t.lvl - sub.lvl) = 1 and u.lvl > 0);
    set @all_children = (select count(1)
            from tree t
            join users u   
                on t.user_id = u.user_id
            join (select * from tree where user_id = @us_id ) sub
                on (sub.lft < t.lft and sub.rgt > t.rgt) 
                where (t.lvl - sub.lvl) <= (select lvl from users where user_id = @us_id) 
            and u.lvl > 0);
    set @new_first_lvl = (select count(1)
            from tree t
            join users u   
                on t.user_id = u.user_id
            join (select * from tree where user_id = @us_id ) sub
                on (sub.lft < t.lft and sub.rgt > t.rgt) where u.when_joined = date_format(date_sub(now(), interval 1 day), '%y-%m-%d' ));
    set @earned_yesterday = (select ifnull(sum(value_of_payment),0) from outcomming_payments 
                where date_format(time_of_act, '%y-%m-%d') = date_format(date_sub(now(), interval 1 day), '%y-%m-%d') 
                and user_id = @us_id
                and (is_it_end = 1 and is_it_success = 1));
    set @erned_all = (select ifnull(sum(value_of_payment),0) from outcomming_payments 
                where user_id = @us_id 
                and (is_it_end = 1 and is_it_success = 1));
    set @balance = (select balance from users where user_id = @us_id );
    set @children_nex_lvl = (select count(1)
            from tree t
            join users u   
                on t.user_id = u.user_id
            join (select * from tree where user_id = @us_id  ) sub
                on (sub.lft < t.lft and sub.rgt > t.rgt) 
            where (t.lvl - sub.lvl) = (select lvl from users where user_id = @us_id ) + 1 );
            
     insert into daily_response(user_id, user_lvl, children_first_lvl, all_children, new_first_lvl, earned_yesterday, erned_all, balance, children_nex_lvl)
                        value (@us_id , @u_lvl, @children_first_lvl, @all_children, @new_first_lvl, @earned_yesterday, @erned_all, @balance, @children_nex_lvl);
end;$$
delimiter 

我在 python 中如何称呼它:

def users_response_db(self,data):
    self.cur.execute(f"call daily_users('{data}')")
    self.conn.commit()
    my_execute = f""";
                    select * from daily_response
                    where user_id = '{data}' 
                    order by id_daily desc
                    limit 1;"""
    self.cur.execute(my_execute)
    return self.cur.fetchone()

我已经尝试使用 SET sql_mode = 'NO_UNSIGNED_SUBTRACTION';

问题出在这部分代码

(select * from tree where user_id = @us_id )

我不需要使用这个子表中的所有内容。 当我用所需的列替换 * 时,我解决了这个问题。在我的解决方案中,它看起来像这样:

(select lft,rgt,lvl from tree where user_id = @us_id )