Open SergiusAC opened 1 week ago
I need to execute INSERT query where some columns should be null. How can I do this?
My code example:
query = """ DECLARE $user_id AS String; DECLARE $tg_user_id AS String; DECLARE $activate_token AS String; DECLARE $notifications_enabled AS Bool; DECLARE $created_at AS Datetime; INSERT INTO tg_users (user_id, tg_user_id, activate_token, notifications_enabled, created_at) VALUES ($user_id, $tg_user_id, $activate_token, $notifications_enabled, $created_at); """ params = { "$user_id": (user_id.encode(), ydb.PrimitiveType.String), "$tg_user_id": None, # this column should be NULL "$activate_token": (activate_token.encode(), ydb.PrimitiveType.String), "$notifications_enabled": (notifications_enabled, ydb.PrimitiveType.Bool), "$created_at": (int(datetime.now().timestamp()), ydb.PrimitiveType.Datetime), } async with await self.tx.execute(query, params): pass
I need to execute INSERT query where some columns should be null. How can I do this?
My code example: