I transferred a Python program from my NixOS laptop to a Raspberry Pi running Debian Bookworm. The program uses sqlite3 and expects an SQLite IF() function, but the Pi reports that the function does not exist. The Pi has Python 3.11, and its SQLite version is 3.40, while newer releases are available. I have already run apt update and apt upgrade, but the packages remain at those versions. Why aren't the latest versions available, and what is the safest way to get the program working?
4 Answers
The SQLite version may not actually be the main problem. SQLite does not generally provide a MySQL-style IF() function. Rewrite the query using CASE, or use SQLite's supported conditional function if your required version provides it. If the SQL comes from another database system, check that it is compatible with SQLite instead of upgrading the entire operating system.
Avoid replacing the system Python just to satisfy one application. Install the required Python version in an isolated environment using a tool such as uv, pyenv, or a virtual environment, then install the application's dependencies there. This prevents changes to the Python packages used by the operating system.
Debian-based stable systems intentionally keep older, well-tested package versions. If apt says everything is current, SQLite 3.40 is likely the newest version provided for that release; apt will not normally replace it with the newest upstream release. You could use a distribution with faster-moving packages, such as Arch Linux ARM, openSUSE Tumbleweed, Alpine, or Ubuntu, but Raspberry Pi hardware support and configuration may require extra work.
If you truly need a newer SQLite than Debian supplies, compile SQLite separately or build the Python sqlite3 module against that installation. Do this in an isolated prefix rather than overwriting the system libraries, because replacing system SQLite can break package-management tools and other applications.

Enabling Debian Testing or Unstable repositories is another possibility, but mixing them with the stable Pi system can introduce dependency conflicts and may break hardware-specific tools or configuration. It is usually safer to use a separate installation or build only the software you need.