The local government said 37 students and two adults suffered injuries of varying degrees in the stabbing, which took place at about 8.30am local time on Thursday.
Chinese state media identified the alleged attacker as a security guard at the school in Wangfu township, in the city of Wuzhou.
The suspect has been detained by police.
According to The Global Times, 37 of the victims suffered minor injuries while two were badly hurt. None of the injuries are thought to be life-threatening.
The motive behind the attack remains unknown.
A parent who was near the scene of the attack told Shanghai-government backed media website The Paper that many of the injured children were about six years old.
A number of deadly attacks have taken place at schools in China over recent years, prompting security upgrades.
Authorities have blamed those incidents largely on people bearing grudges or having unidentified mental illnesses.
In earlier attacks, a woman wielding a knife injured 14 children at a kindergarten in the western city of Chongqing in October 2018.
Almost 20 children were killed in school attacks in 2010, prompting a response from top government officials and resulting in many schools adding gates and security guards.
Chinese law restricts the sale and possession of firearms, and mass attacks are generally carried out with knives or homemade explosives.
Additional reporting by Associated Press
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies