The carbon monoxide rovibrational emission from discs around Herbig Ae stars and T Tauri stars with strong ultraviolet emissions suggests that fluorescence pumping from the ground X1 Sigma+ to the electronic A1 Pi state of CO should be taken into account in disc models. We implemented a CO model molecule that includes up to 50 rotational levels within nine vibrational levels for the ground and A excited states in the radiative photochemical code ProDiMo. We took CO collisions with hydrogen molecules, hydrogen atoms, helium, and electrons into account. We estimated the missing collision rates using standard scaling laws and discussed their limitations. UV fluorescence and IR pumping impact on the population of ro-vibrational v > 1 levels. The v = 1 rotational levels are populated at rotational temperatures between the radiation temperature around 4.6 micron and the gas kinetic temperature. The UV pumping efficiency increases with decreasing disc mass. The consequence is that the vibrational temperatures, which measure the relative populations between the vibrational levels, are higher than the disc gas kinetic temperatures (suprathermal population). Rotational temperatures from fundamental transitions derived using optically thick 12CO lines do not reflect the gas kinetic temperature. CO pure rotational levels with energies lower than 1000 K are populated in LTE but are sensitive to a number of vibrational levels included in the model. The 12CO pure rotational lines are highly optically thick for transition from levels up to Eupper=2000 K. (abridged)